mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
test _zypper_check_result()
This commit is contained in:
parent
aff6467782
commit
f266cfdaac
1 changed files with 50 additions and 0 deletions
|
@ -64,6 +64,56 @@ class ZypperTestCase(TestCase):
|
|||
assert pkg in upgrades
|
||||
assert upgrades[pkg] == version
|
||||
|
||||
def test_zypper_check_result(self):
|
||||
'''
|
||||
Test zypper check result function
|
||||
'''
|
||||
cmd_out = {
|
||||
'retcode': 1,
|
||||
'stdout': '',
|
||||
'stderr': 'This is an error'
|
||||
}
|
||||
with self.assertRaisesRegexp(CommandExecutionError, "^zypper command failed: This is an error$"):
|
||||
zypper._zypper_check_result(cmd_out)
|
||||
|
||||
cmd_out = {
|
||||
'retcode': 0,
|
||||
'stdout': 'result',
|
||||
'stderr': ''
|
||||
}
|
||||
out = zypper._zypper_check_result(cmd_out)
|
||||
self.assertEqual(out, "result")
|
||||
|
||||
cmd_out = {
|
||||
'retcode': 1,
|
||||
'stdout': '',
|
||||
'stderr': 'This is an error'
|
||||
}
|
||||
with self.assertRaisesRegexp(CommandExecutionError, "^zypper command failed: This is an error$"):
|
||||
zypper._zypper_check_result(cmd_out, xml=True)
|
||||
|
||||
cmd_out = {
|
||||
'retcode': 1,
|
||||
'stdout': '',
|
||||
'stderr': ''
|
||||
}
|
||||
with self.assertRaisesRegexp(CommandExecutionError, "^zypper command failed: Check zypper logs$"):
|
||||
zypper._zypper_check_result(cmd_out, xml=True)
|
||||
|
||||
cmd_out = {
|
||||
'stdout': '''<?xml version='1.0'?>
|
||||
<stream>
|
||||
<message type="info">Refreshing service 'container-suseconnect'.</message>
|
||||
<message type="error">Some handled zypper internal error</message>
|
||||
<message type="error">Another zypper internal error</message>
|
||||
</stream>
|
||||
''',
|
||||
'stderr': '',
|
||||
'retcode': 1
|
||||
}
|
||||
with self.assertRaisesRegexp(CommandExecutionError, "^zypper command failed: Some handled zypper internal error\nAnother zypper internal error$"):
|
||||
zypper._zypper_check_result(cmd_out, xml=True)
|
||||
|
||||
def test_list_upgrades_error_handling(self):
|
||||
'''
|
||||
Test error handling in the list package upgrades.
|
||||
|
|
Loading…
Add table
Reference in a new issue