From 9f5a1a7f4b6309a2c562726a176cdc70d1df0593 Mon Sep 17 00:00:00 2001 From: "Gareth J. Greenaway" Date: Tue, 19 Dec 2023 17:30:11 -0800 Subject: [PATCH] Include changes in the results when schedule.present state is run with test=True. --- changelog/65652.fixed.md | 1 + salt/states/schedule.py | 1 + tests/pytests/unit/states/test_schedule.py | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelog/65652.fixed.md diff --git a/changelog/65652.fixed.md b/changelog/65652.fixed.md new file mode 100644 index 000000000000..2f93147a2338 --- /dev/null +++ b/changelog/65652.fixed.md @@ -0,0 +1 @@ +Include changes in the results when schedule.present state is run with test=True. diff --git a/salt/states/schedule.py b/salt/states/schedule.py index 58937138378d..db02e90a82f5 100644 --- a/salt/states/schedule.py +++ b/salt/states/schedule.py @@ -264,6 +264,7 @@ def present(name, **kwargs): kwargs["test"] = True result = __salt__["schedule.add"](name, **kwargs) ret["comment"].append(result["comment"]) + ret["changes"] = {name: "added"} else: result = __salt__["schedule.add"](name, **kwargs) if not result["result"]: diff --git a/tests/pytests/unit/states/test_schedule.py b/tests/pytests/unit/states/test_schedule.py index 505bb3b5eb87..3d34979a0c22 100644 --- a/tests/pytests/unit/states/test_schedule.py +++ b/tests/pytests/unit/states/test_schedule.py @@ -220,7 +220,7 @@ def test_present(): ret = { "name": "job1", "result": True, - "changes": {}, + "changes": {"job1": "added"}, "comment": "Job: test-schedule would be added to schedule.", } with patch.dict(schedule.__opts__, {"test": True}):