mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #35451 from isbm/isbm-zypper-mod_repo-unchanged
Bugfix: zypper mod repo unchanged
This commit is contained in:
commit
1473474b04
2 changed files with 10 additions and 16 deletions
|
@ -806,6 +806,7 @@ def mod_repo(repo, **kwargs):
|
|||
cmd_opt = global_cmd_opt + ['mr'] + cmd_opt + [repo]
|
||||
__zypper__.refreshable.xml.call(*cmd_opt)
|
||||
|
||||
comment = None
|
||||
if call_refresh:
|
||||
# when used with "zypper ar --refresh" or "zypper mr --refresh"
|
||||
# --gpg-auto-import-keys is not doing anything
|
||||
|
@ -813,11 +814,13 @@ def mod_repo(repo, **kwargs):
|
|||
refresh_opts = global_cmd_opt + ['refresh'] + [repo]
|
||||
__zypper__.xml.call(*refresh_opts)
|
||||
elif not added and not cmd_opt:
|
||||
raise CommandExecutionError(
|
||||
'Specified arguments did not result in modification of repo'
|
||||
)
|
||||
comment = 'Specified arguments did not result in modification of repo'
|
||||
|
||||
return get_repo(repo)
|
||||
repo = get_repo(repo)
|
||||
if comment:
|
||||
repo['comment'] = comment
|
||||
|
||||
return repo
|
||||
|
||||
|
||||
def refresh_db():
|
||||
|
|
|
@ -73,7 +73,7 @@ class ZypperTestCase(TestCase):
|
|||
self.zypper_patcher_config = {
|
||||
'_get_configured_repos': Mock(side_effect=side_effect),
|
||||
'__zypper__': Mock(),
|
||||
'get_repo': Mock()
|
||||
'get_repo': Mock(return_value={})
|
||||
}
|
||||
|
||||
def test_list_upgrades(self):
|
||||
|
@ -493,17 +493,8 @@ class ZypperTestCase(TestCase):
|
|||
'salt.modules.zypper', **self.zypper_patcher_config)
|
||||
|
||||
with zypper_patcher:
|
||||
with self.assertRaisesRegexp(
|
||||
Exception,
|
||||
'Specified arguments did not result in modification of repo'
|
||||
):
|
||||
zypper.mod_repo(name, **{'url': url})
|
||||
with self.assertRaisesRegexp(
|
||||
Exception,
|
||||
'Specified arguments did not result in modification of repo'
|
||||
):
|
||||
zypper.mod_repo(name, **{'url': url, 'gpgautoimport': 'a'})
|
||||
|
||||
self.assertEqual(zypper.mod_repo(name, **{'url': url}),
|
||||
{'comment': 'Specified arguments did not result in modification of repo'})
|
||||
zypper.__zypper__.xml.call.assert_not_called()
|
||||
zypper.__zypper__.refreshable.xml.call.assert_not_called()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue