forked from saltstack/salt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
salt-pip
now properly errors out when being called from a non `oned…
…ir` environment. Fixes saltstack#64249 Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
- Loading branch information
Showing
3 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
`salt-pip` now properly errors out when being called from a non `onedir` environment. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
import salt.scripts | ||
import salt.utils.platform | ||
from tests.conftest import CODE_DIR | ||
from tests.support.mock import patch | ||
|
||
|
||
def test_within_onedir_env(shell): | ||
if os.environ.get("ONEDIR_TESTRUN", "0") == "0": | ||
return | ||
|
||
script_name = "salt-pip" | ||
if salt.utils.platform.is_windows(): | ||
script_name += ".exe" | ||
|
||
script_path = CODE_DIR / "artifacts" / "salt" / script_name | ||
assert script_path.exists() | ||
|
||
ret = shell.run(str(script_path), "list") | ||
assert ret.returncode == 0 | ||
|
||
|
||
def test_outside_onedir_env(capsys): | ||
with patch("salt.scripts._get_onedir_env_path", return_value=None): | ||
with pytest.raises(SystemExit) as exc: | ||
salt.scripts.salt_pip() | ||
captured = capsys.readouterr() | ||
assert "'salt-pip' is only meant to be used from a Salt onedir." in captured.err |