def test_docker_cmd_nocleanup(self): dig = DockerImageGenerator([], {}, 'ubuntu:bionic') self.assertIn('--rm', dig.generate_docker_cmd()) self.assertIn('--rm', dig.generate_docker_cmd(mode='dry-run')) self.assertIn('--rm', dig.generate_docker_cmd(nocleanup='')) self.assertNotIn('--rm', dig.generate_docker_cmd(nocleanup='true'))
def test_docker_cmd_interactive(self): dig = DockerImageGenerator([], {}, 'ubuntu:bionic') self.assertNotIn('-it', dig.generate_docker_cmd(mode='')) self.assertIn('-it', dig.generate_docker_cmd(mode='dry-run')) # TODO(tfoote) mock this appropriately # google actions tests don't have a tty, local tests do import os, sys if os.isatty(sys.__stdin__.fileno()): self.assertIn('-it', dig.generate_docker_cmd(mode='interactive')) else: self.assertNotIn('-it', dig.generate_docker_cmd(mode='interactive')) self.assertNotIn('-it', dig.generate_docker_cmd(mode='non-interactive'))