Merge pull request #35569 from rallytime/test-for-35384

Write test for multiple unless commands where 1st cmd passes and 2nd fails
This commit is contained in:
Thomas S Hatch 2016-08-19 13:28:01 -06:00 committed by GitHub
commit c9070c212f
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