Write test for multiple unless commands where 1st cmd passes and 2nd fails

This is a regression integration test for #35384, which was fixed by #35545,
and back-ported to the 2015.8 branch in #35566.
This commit is contained in:
rallytime 2016-08-18 11:01:32 -06:00
parent 2a5d1a0eee
commit 30f42d5352
2 changed files with 22 additions and 0 deletions

View file

@ -0,0 +1,6 @@
cmd_run_unless_multiple:
cmd.run:
- name: echo "hello"
- unless:
- /bin/true
- /bin/false

View file

@ -87,6 +87,22 @@ class CMDTest(integration.ModuleCase,
os.remove(state_file)
os.remove(unless_file)
def test_run_unless_multiple_cmds(self):
'''
test cmd.run using multiple unless options where the first cmd in the
list will pass, but the second will fail. This tests the fix for issue
#35384. (The fix is in PR #35545.)
'''
sls = self.run_function('state.sls', mods='issue-35384')
self.assertSaltTrueReturn(sls)
# We must assert against the comment here to make sure the comment reads that the
# command "echo "hello"" was run. This ensures that we made it to the last unless
# command in the state. If the comment reads "unless execution succeeded", or similar,
# then the unless state run bailed out after the first unless command succeeded,
# which is the bug we're regression testing for.
self.assertEqual(sls['cmd_|-cmd_run_unless_multiple_|-echo "hello"_|-run']['comment'],
'Command "echo "hello"" run')
def test_run_creates_exists(self):
'''
test cmd.run creates already there