From f597c142632beb80a11bf323aef958dcc168f890 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?= Date: Mon, 13 Nov 2023 12:29:45 +0000 Subject: [PATCH] Add unit tests to check path is expanded --- tests/pytests/unit/config/test_master_config.py | 12 ++++++++++++ tests/pytests/unit/config/test_minion_config.py | 13 +++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tests/pytests/unit/config/test_minion_config.py diff --git a/tests/pytests/unit/config/test_master_config.py b/tests/pytests/unit/config/test_master_config.py index 527f944e0ea..5de8cd18c9f 100644 --- a/tests/pytests/unit/config/test_master_config.py +++ b/tests/pytests/unit/config/test_master_config.py @@ -1,4 +1,5 @@ import salt.config +from tests.support.mock import MagicMock, patch def test_apply_no_cluster_id(): @@ -60,3 +61,14 @@ def test_apply_for_cluster(): assert isinstance(opts["cluster_peers"], list) opts["cluster_peers"].sort() assert ["127.0.0.1", "127.0.0.3"] == opts["cluster_peers"] + + +def test___cli_path_is_expanded(): + defaults = salt.config.DEFAULT_MASTER_OPTS.copy() + overrides = {} + with patch( + "salt.utils.path.expand", MagicMock(return_value="/path/to/testcli") + ) as expand_mock: + opts = salt.config.apply_master_config(overrides, defaults) + assert expand_mock.called + assert opts["__cli"] == "testcli" diff --git a/tests/pytests/unit/config/test_minion_config.py b/tests/pytests/unit/config/test_minion_config.py new file mode 100644 index 00000000000..34aa84daa74 --- /dev/null +++ b/tests/pytests/unit/config/test_minion_config.py @@ -0,0 +1,13 @@ +import salt.config +from tests.support.mock import MagicMock, patch + + +def test___cli_path_is_expanded(): + defaults = salt.config.DEFAULT_MINION_OPTS.copy() + overrides = {} + with patch( + "salt.utils.path.expand", MagicMock(return_value="/path/to/testcli") + ) as expand_mock: + opts = salt.config.apply_minion_config(overrides, defaults) + assert expand_mock.called + assert opts["__cli"] == "testcli"