mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix more ssh tests
This commit is contained in:
parent
6f5c0ac2e7
commit
d53a8c74ba
3 changed files with 15 additions and 12 deletions
|
@ -89,8 +89,8 @@ class SSHCommandExecutionError(SSHException, CommandExecutionError):
|
|||
|
||||
def __str__(self):
|
||||
ret = self.to_ret()
|
||||
if isinstance(ret, str):
|
||||
return f"{self._error}: {ret}"
|
||||
if self.retcode > 0:
|
||||
return f"{self._error}: {self.stderr or self.stdout}"
|
||||
return self._error
|
||||
|
||||
|
||||
|
|
|
@ -87,5 +87,5 @@ def test_it(salt_ssh_cli, args):
|
|||
|
||||
assert ret.returncode == EX_AGGREGATE
|
||||
assert ret.data
|
||||
assert isinstance(ret.data, str)
|
||||
assert "ComplianceError: 'Outlaw detected'" in ret.data
|
||||
assert isinstance(ret.data, dict)
|
||||
assert "ComplianceError: 'Outlaw detected'" in ret.data["stderr"]
|
||||
|
|
|
@ -220,10 +220,10 @@ def test_retcode_exe_run_fail(salt_ssh_cli):
|
|||
"""
|
||||
ret = salt_ssh_cli.run("file.touch", "/tmp/non/ex/is/tent")
|
||||
assert ret.returncode == EX_AGGREGATE
|
||||
assert isinstance(ret.data, str)
|
||||
assert isinstance(ret.data, dict)
|
||||
# This should be the exact output, but some other warnings
|
||||
# might be printed to stderr.
|
||||
assert "Error running 'file.touch': No such file or directory" in ret.data
|
||||
assert "Error running 'file.touch': No such file or directory" in ret.data["stderr"]
|
||||
|
||||
|
||||
def test_retcode_exe_run_exception(salt_ssh_cli):
|
||||
|
@ -233,8 +233,8 @@ def test_retcode_exe_run_exception(salt_ssh_cli):
|
|||
"""
|
||||
ret = salt_ssh_cli.run("salttest.jinja_error")
|
||||
assert ret.returncode == EX_AGGREGATE
|
||||
assert isinstance(ret.data, str)
|
||||
assert ret.data.endswith("Exception: hehehe")
|
||||
assert isinstance(ret.data, dict)
|
||||
assert ret.data["stderr"].endswith("Exception: hehehe")
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("invalid_json_exe_mod")
|
||||
|
@ -276,10 +276,13 @@ def test_wrapper_unwrapped_command_exception(salt_ssh_cli):
|
|||
"""
|
||||
ret = salt_ssh_cli.run("check_exception.failure")
|
||||
assert ret.returncode == EX_AGGREGATE
|
||||
assert isinstance(ret.data, str)
|
||||
assert isinstance(ret.data, dict)
|
||||
assert ret.data
|
||||
assert "Probably got garbage" not in ret.data
|
||||
assert "Error running 'disk.usage': Invalid flag passed to disk.usage" in ret.data
|
||||
assert "Probably got garbage" not in ret.data["stderr"]
|
||||
assert (
|
||||
"Error running 'disk.usage': Invalid flag passed to disk.usage"
|
||||
in ret.data["stderr"]
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("remote_parsing_failure_wrap_mod", "invalid_json_exe_mod")
|
||||
|
@ -290,7 +293,7 @@ def test_wrapper_unwrapped_command_parsing_failure(salt_ssh_cli):
|
|||
ret = salt_ssh_cli.run("check_parsing.failure", "whoops")
|
||||
assert ret.returncode == EX_AGGREGATE
|
||||
assert ret.data
|
||||
assert "Probably got garbage" not in ret.data
|
||||
assert "Probably got garbage" not in ret.data["stderr"]
|
||||
assert isinstance(ret.data, dict)
|
||||
assert ret.data["_error"] == "Failed to return clean data"
|
||||
assert ret.data["retcode"] == 0
|
||||
|
|
Loading…
Add table
Reference in a new issue