Exemplo n.º 1
0
    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': {}
        })
Exemplo n.º 2
0
    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': {}
        })
Exemplo n.º 3
0
 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': {}})
Exemplo n.º 4
0
 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': {}
         })
Exemplo n.º 5
0
    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': {}})
Exemplo n.º 6
0
    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': {}})