def test_docker_run_failure(self): from salt.states import dockerio salt_fixture = { 'docker.retcode': MagicMock(return_value=0), 'docker.run_all': MagicMock( return_value={ 'stdout': '', 'stderr': 'Error', 'status': False, 'comment': 'Failure', 'retcode': 1 }) } with provision_state(dockerio, salt_fixture): result = dockerio.run('ls /', 'ubuntu') self.assertEqual(result, { 'name': 'ls /', 'result': False, 'comment': 'Failure', 'changes': {} })
def test_docker_run_success(self): from salt.states import dockerio salt_fixture = { 'docker.retcode': MagicMock(return_value=0), 'docker.run_all': MagicMock( return_value={ 'stdout': '.\n..\n', 'stderr': '', 'status': True, 'comment': 'Success', 'retcode': 0 }) } with provision_state(dockerio, salt_fixture): result = dockerio.run('ls /', 'ubuntu') self.assertEqual(result, { 'name': 'ls /', 'result': True, 'comment': 'Success', 'changes': {} })
def test_docker_run_docked_onlyif(self): from salt.states import dockerio salt_fixture = {'docker.retcode': MagicMock(return_value=1), 'docker.run_all': None} with provision_state(dockerio, salt_fixture): result = dockerio.run('ls /', 'ubuntu', docked_onlyif='ls -l') self.assertEqual(result, {'name': 'ls /', 'result': True, 'comment': 'docked_onlyif execution failed', 'changes': {}})
def test_docker_run_unless(self): from salt.states import dockerio salt_fixture = { 'docker.retcode': MagicMock(return_value=0), 'docker.run_all': None } with provision_state(dockerio, salt_fixture): result = dockerio.run('ls /', 'ubuntu', unless='ls -l') self.assertEqual( result, { 'name': 'ls /', 'result': True, 'comment': 'unless execution succeeded', 'changes': {} })
def test_docker_run_failure(self): from salt.states import dockerio salt_fixture = {'docker.retcode': MagicMock(return_value=0), 'docker.run_all': MagicMock( return_value={'stdout': '', 'stderr': 'Error', 'status': False, 'comment': 'Failure', 'retcode': 1})} with provision_state(dockerio, salt_fixture): result = dockerio.run('ls /', 'ubuntu') self.assertEqual(result, {'name': 'ls /', 'result': False, 'comment': 'Failure', 'changes': {}})
def test_docker_run_success(self): from salt.states import dockerio salt_fixture = {'docker.retcode': MagicMock(return_value=0), 'docker.run_all': MagicMock( return_value={'stdout': '.\n..\n', 'stderr': '', 'status': True, 'comment': 'Success', 'retcode': 0})} with provision_state(dockerio, salt_fixture): result = dockerio.run('ls /', 'ubuntu') self.assertEqual(result, {'name': 'ls /', 'result': True, 'comment': 'Success', 'changes': {}})