From 79862771f37af552c190a6cef36204729978a74a Mon Sep 17 00:00:00 2001 From: vzhestkov Date: Mon, 8 Jul 2024 13:31:41 +0200 Subject: [PATCH] Add test to check extension_modules value alignment --- tests/pytests/unit/cli/test_salt_call.py | 32 ++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/pytests/unit/cli/test_salt_call.py diff --git a/tests/pytests/unit/cli/test_salt_call.py b/tests/pytests/unit/cli/test_salt_call.py new file mode 100644 index 0000000000..078f2af70d --- /dev/null +++ b/tests/pytests/unit/cli/test_salt_call.py @@ -0,0 +1,32 @@ +import os + +from salt.cli.call import SaltCall +from tests.support.mock import MagicMock, patch + + +def test_passing_cachedir_to_extension_modules(temp_salt_minion): + """ + Test passing `cachedir` CLI parameter to `extension_modules` opts + """ + test_cache_dir = os.path.join(temp_salt_minion.config["root_dir"], "new_cache_tmp") + with patch( + "sys.argv", + [ + "salt-call", + "--local", + "--config-dir", + temp_salt_minion.config["root_dir"], + "--cachedir", + test_cache_dir, + "test.true", + ], + ), patch("salt.utils.verify.verify_files", MagicMock()), patch( + "salt._logging.impl.setup_logfile_handler", MagicMock() + ): + salt_call = SaltCall() + with patch("salt.cli.caller.Caller.factory", MagicMock()) as caller_mock: + salt_call.run() + assert salt_call.config["cachedir"] == test_cache_dir + assert salt_call.config["extension_modules"] == os.path.join( + test_cache_dir, "extmods" + )