fixes saltstack/salt#64150 cmd.run doesn't output changes in test mode

This commit is contained in:
nicholasmhughes 2023-04-24 14:53:22 -04:00 committed by Pedro Algarvio
parent 99cb7c0e08
commit 98ecf8d45c
3 changed files with 5 additions and 1 deletions

1
changelog/64150.fixed.md Normal file
View file

@ -0,0 +1 @@
Fix cmd.run doesn't output changes in test mode

View file

@ -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):

View file

@ -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