Merge pull request #48534 from xetix/fix-zypper-latest_version

Fix behaviour of function latest_version in zypper module when multip…
This commit is contained in:
Nicole Thomas 2018-07-13 15:56:05 -04:00 committed by GitHub
commit 6973152057
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View file

@ -581,6 +581,8 @@ def latest_version(*names, **kwargs):
status = pkg_info.get('status', '').lower()
if status.find('not installed') > -1 or status.find('out-of-date') > -1:
ret[name] = pkg_info.get('version')
else:
ret[name] = ''
# Return a string if only one package name passed
if len(names) == 1 and len(ret):

View file

@ -361,6 +361,7 @@ class ZypperTestCase(TestCase, LoaderModuleMockMixin):
ZyppCallMock(return_value=get_test_data('zypper-available.txt'))), \
patch('salt.modules.zypper.refresh_db', MagicMock(return_value=True)):
self.assertEqual(zypper.latest_version('vim'), '7.4.326-2.62')
self.assertDictEqual(zypper.latest_version('vim', 'fakepkg'), {'vim': '7.4.326-2.62', 'fakepkg': ''})
def test_upgrade_success(self):
'''