diff --git a/changelog/62654.fixed b/changelog/62654.fixed new file mode 100644 index 00000000000..67a265040ad --- /dev/null +++ b/changelog/62654.fixed @@ -0,0 +1 @@ +Fix saltcheck _get_top_states doesn't pass saltenv to state.show_top diff --git a/salt/modules/saltcheck.py b/salt/modules/saltcheck.py index e3b32f2916b..ac499558878 100644 --- a/salt/modules/saltcheck.py +++ b/salt/modules/saltcheck.py @@ -651,7 +651,7 @@ def _get_top_states(saltenv="base"): Equivalent to a salt cli: salt web state.show_top """ top_states = [] - top_states = __salt__["state.show_top"]()[saltenv] + top_states = __salt__["state.show_top"](saltenv=saltenv)[saltenv] log.debug("saltcheck for saltenv: %s found top states: %s", saltenv, top_states) return top_states diff --git a/tests/pytests/unit/modules/test_saltcheck.py b/tests/pytests/unit/modules/test_saltcheck.py new file mode 100644 index 00000000000..2b27cba98e4 --- /dev/null +++ b/tests/pytests/unit/modules/test_saltcheck.py @@ -0,0 +1,15 @@ +import pytest + +import salt.modules.saltcheck as saltcheck +from tests.support.mock import MagicMock + + +@pytest.fixture() +def configure_loader_modules(): + return {saltcheck: {"__salt__": {"state.show_top": MagicMock()}}} + + +@pytest.mark.parametrize("saltenv", ["base", "dev", "howdy"]) +def test__get_top_states_call_args(saltenv): + saltcheck._get_top_states(saltenv=saltenv) + saltcheck.__salt__["state.show_top"].assert_called_with(saltenv=saltenv)