def test_constructor(self): # this checks that an exception is raised for invalid arguments msg = 'No command was provided' with pytest.raises(ValueError, match=msg): ShellCommand() cmd = ShellCommand(command='something') assert cmd.command == util.FlattenList(['something']) cmd = ShellCommand(command='something', args=['arg1', 'arg2']) assert cmd.command == util.FlattenList(['something', ['arg1', 'arg2']]) cmd = ShellCommand(command=['echo', '1']) assert cmd.command == util.FlattenList([('echo', '1')]) cmd = MyDockerCommand(args=['--help']) assert cmd.command == util.FlattenList([['my-docker-binary'], ['--help']])
async def test_echo(self): self.setupStep( ShellCommand(command=['echo', '1'], workdir='build') ) self.expectCommands( ExpectShell(workdir='build', command=['echo', '1']) + 0 ) self.expectOutcome(result=SUCCESS) return await self.runStep()
async def test_run_property_from_another_command(self): command = ShellCommand(command='echo', args=['something', 'else']) self.setupStep( SetPropertyFromCommand( property='echoed', command=command, workdir='build', )) self.expectCommands( ExpectShell(workdir='build', command=['echo', 'something', 'else']) + ExpectShell.log('stdio', stdout='something else') + 0) self.expectLogfile('stdio', 'something else') self.expectOutcome(result=SUCCESS) self.expectProperty('echoed', 'something else') return await self.runStep()
# loading MASTER_FQDN from .env file, required for OSX load_dotenv() name = 'test' repo = 'https://github.com/ursa-labs/ursabot' images = worker_images_for([ DockerImage('test', base='python:3.7', os='debian-9', arch='amd64') ]) workers = docker_workers_for( archs=['amd64'], masterFQDN=os.getenv('MASTER_FQDN') ) echoer = DockerBuilder('echoer', image=images[0], workers=workers, steps=[ ShellCommand(command='echo 1337', as_shell=True) ]) failer = DockerBuilder('failer', image=images[0], workers=workers, steps=[ ShellCommand(command='unknown-command', as_shell=True) ]) builders = [echoer, failer] schedulers = [ AnyBranchScheduler(name='TestScheduler', builders=builders) ] project = ProjectConfig( name=name, repo=repo, images=images, workers=workers, builders=builders,
worker_image = worker_image_for(image) images = ImageCollection([image, worker_image]) workers = [ DockerLatentWorker('local-worker', password=None, platform=Platform.detect(), docker_host='unix:///var/run/docker.sock', hostconfig={'network_mode': 'host'}, masterFQDN=os.getenv('MASTER_FQDN', 'localhost')) ] echoer = DockerBuilder( name='echoer', image=worker_image, workers=workers, steps=[ShellCommand(command='echo 1337', as_shell=True)]) failer = DockerBuilder( name='failer', image=worker_image, workers=workers, steps=[ShellCommand(command='unknown-command', as_shell=True)]) builders = [echoer, failer] schedulers = [AnyBranchScheduler(name='TestScheduler', builders=builders)] project = ProjectConfig(name=name, repo=repo, images=images, workers=workers, builders=builders, schedulers=schedulers) master = MasterConfig(title='Test', projects=[project])