mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
Enhance error messages in zypperpkg module
Enhance capture of error messages for Zypper calls in zypperpkg module.
This commit is contained in:
parent
2c8088f005
commit
6312d20b4f
2 changed files with 11 additions and 1 deletions
|
@ -294,6 +294,10 @@ class _Zypper:
|
|||
self.__call_result["stderr"]
|
||||
and self.__call_result["stderr"].strip()
|
||||
or ""
|
||||
) or (
|
||||
self.__call_result["stdout"]
|
||||
and self.__call_result["stdout"].strip()
|
||||
or ""
|
||||
)
|
||||
if msg:
|
||||
_error_msg.append(msg)
|
||||
|
|
|
@ -203,11 +203,17 @@ class ZypperTestCase(TestCase, LoaderModuleMockMixin):
|
|||
):
|
||||
zypper.__zypper__.xml.call("crashme")
|
||||
|
||||
output_to_user = "Output to user"
|
||||
sniffer = RunSniffer(stdout=output_to_user, retcode=1)
|
||||
with patch.dict("salt.modules.zypperpkg.__salt__", {"cmd.run_all": sniffer}):
|
||||
with self.assertRaisesRegex(
|
||||
CommandExecutionError, "^Zypper command failure: Check Zypper's logs.$"
|
||||
CommandExecutionError,
|
||||
"^Zypper command failure: {}$".format(output_to_user),
|
||||
):
|
||||
zypper.__zypper__.call("crashme again")
|
||||
|
||||
sniffer = RunSniffer(retcode=1)
|
||||
with patch.dict("salt.modules.zypperpkg.__salt__", {"cmd.run_all": sniffer}):
|
||||
zypper.__zypper__.noraise.call("stay quiet")
|
||||
self.assertEqual(zypper.__zypper__.error_msg, "Check Zypper's logs.")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue