Skip to content

Commit

Permalink
fixes #64150 cmd.run doesn't output changes in test mode
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasmhughes authored and s0undt3ch committed Apr 27, 2023
1 parent 99cb7c0 commit 98ecf8d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/64150.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix cmd.run doesn't output changes in test mode
1 change: 1 addition & 0 deletions salt/states/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,7 @@ def run(
if __opts__["test"] and not test_name:
ret["result"] = None
ret["comment"] = 'Command "{}" would have been executed'.format(name)
ret["changes"] = {"cmd": name}
return _reinterpreted_state(ret) if stateful else ret

if cwd and not os.path.isdir(cwd):
Expand Down
4 changes: 3 additions & 1 deletion tests/pytests/unit/states/test_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ def test_run():

with patch.dict(cmd.__opts__, {"test": True}):
comt = 'Command "cmd.script" would have been executed'
ret.update({"comment": comt, "result": None, "changes": {}})
ret.update(
{"comment": comt, "result": None, "changes": {"cmd": "cmd.script"}}
)
assert cmd.run(name) == ret


Expand Down

0 comments on commit 98ecf8d

Please sign in to comment.