Skip to content

Commit

Permalink
Merge pull request #3 from meaksh/set-proper-__cli-tests
Browse files Browse the repository at this point in the history
Add unit tests to check path is expanded
  • Loading branch information
vzhestkov authored Nov 13, 2023
2 parents a9df386 + de663bf commit f8a0101
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 f8a0101

Please sign in to comment.