mirror of
https://github.com/valitydev/salt.git
synced 2024-11-06 16:45:27 +00:00
Add more tests for salt-ssh state.sls_id
This commit is contained in:
parent
dab80e805c
commit
70e36764ee
@ -33,6 +33,9 @@ log = logging.getLogger(__name__)
|
||||
|
||||
def _ssh_state(chunks, __opts__, __context__, __pillar__, __salt__, st_kwargs,
|
||||
kwargs, test=False):
|
||||
'''
|
||||
funciton to run a state with the given chunk via salt-ssh
|
||||
'''
|
||||
file_refs = salt.client.ssh.state.lowstate_file_refs(
|
||||
chunks,
|
||||
_merge_extra_filerefs(
|
||||
|
@ -3,3 +3,7 @@ ssh-file-test:
|
||||
file.managed:
|
||||
- name: /tmp/{{ jinja }}
|
||||
- contents: 'test'
|
||||
|
||||
second_id:
|
||||
cmd.run:
|
||||
- name: echo test
|
||||
|
@ -24,9 +24,12 @@ class SSHStateTest(SSHCase):
|
||||
'''
|
||||
testing the state system with salt-ssh
|
||||
'''
|
||||
def _check_dict_ret(self, ret, val, exp_ret):
|
||||
def _check_dict_ret(self, ret, val, exp_ret, equal=True):
|
||||
for key, value in ret.items():
|
||||
self.assertEqual(value[val], exp_ret)
|
||||
if equal:
|
||||
self.assertEqual(value[val], exp_ret)
|
||||
else:
|
||||
self.assertNotEqual(value[val], exp_ret)
|
||||
|
||||
def _check_request(self, empty=False):
|
||||
check = self.run_function('state.check_request', wipe=False)
|
||||
@ -50,12 +53,32 @@ class SSHStateTest(SSHCase):
|
||||
'''
|
||||
test state.sls_id with salt-ssh
|
||||
'''
|
||||
# check state.sls_id with test=True
|
||||
ret = self.run_function('state.sls_id', ['ssh-file-test', SSH_SLS,
|
||||
'test=True'])
|
||||
self._check_dict_ret(ret=ret, val='comment',
|
||||
exp_ret='The file /tmp/test is set to be changed')
|
||||
|
||||
# check state.sls_id without test=True
|
||||
ret = self.run_function('state.sls_id', ['ssh-file-test', SSH_SLS])
|
||||
self._check_dict_ret(ret=ret, val='__sls__', exp_ret=SSH_SLS)
|
||||
|
||||
# make sure the other id in the state was not run
|
||||
self._check_dict_ret(ret=ret, val='__id__',
|
||||
exp_ret='second_id', equal=False)
|
||||
|
||||
|
||||
check_file = self.run_function('file.file_exists', ['/tmp/test'])
|
||||
self.assertTrue(check_file)
|
||||
|
||||
def test_state_sls_wrong_id(self):
|
||||
'''
|
||||
test state.sls_id when id does not exist
|
||||
'''
|
||||
# check state.sls_id with test=True
|
||||
ret = self.run_function('state.sls_id', ['doesnotexist', SSH_SLS])
|
||||
assert 'No matches for ID' in ret
|
||||
|
||||
def test_state_show_sls(self):
|
||||
'''
|
||||
test state.show_sls with salt-ssh
|
||||
|
Loading…
Reference in New Issue
Block a user