Skip to content

Commit

Permalink
Add unit tests to check path is expanded
Browse files Browse the repository at this point in the history
  • Loading branch information
meaksh authored and dwoz committed Dec 16, 2023
1 parent a5599d6 commit f597c14
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/pytests/unit/config/test_master_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import salt.config
from tests.support.mock import MagicMock, patch


def test_apply_no_cluster_id():
Expand Down Expand Up @@ -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"
13 changes: 13 additions & 0 deletions tests/pytests/unit/config/test_minion_config.py
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit f597c14

Please sign in to comment.