mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
pkgin latest_version bugfix
Handle case where the currently installed package is the latest
This commit is contained in:
parent
4ae0313797
commit
4dac0b4a31
2 changed files with 21 additions and 1 deletions
|
@ -192,7 +192,7 @@ def latest_version(*names, **kwargs):
|
|||
s = _splitpkg(p[0])
|
||||
if s:
|
||||
if not s[0] in pkglist:
|
||||
if len(p) > 1 and p[1] == '<' or p[1] == '':
|
||||
if len(p) > 1 and p[1] in ('<', '', '='):
|
||||
pkglist[s[0]] = s[1]
|
||||
else:
|
||||
pkglist[s[0]] = ''
|
||||
|
|
|
@ -113,6 +113,26 @@ class PkginTestCase(TestCase, LoaderModuleMockMixin):
|
|||
patch.dict(pkgin.__salt__, {'cmd.run': pkgin_search_cmd}):
|
||||
self.assertEqual(pkgin.latest_version('somepkg'), '1.1')
|
||||
|
||||
'''
|
||||
Test getting the latest version of an installed package that is the latest version
|
||||
'''
|
||||
pkgin_out = [
|
||||
'somepkg-1.2;=;Some package description here',
|
||||
'',
|
||||
'=: package is installed and up-to-date',
|
||||
'<: package is installed but newer version is available',
|
||||
'>: installed package has a greater version than available package'
|
||||
]
|
||||
|
||||
pkgin_refresh_db_mock = MagicMock(return_value=True)
|
||||
pkgin_search_cmd = MagicMock(return_value=os.linesep.join(pkgin_out))
|
||||
|
||||
with patch('salt.modules.pkgin.refresh_db', pkgin_refresh_db_mock), \
|
||||
patch('salt.modules.pkgin._get_version', pkgin__get_version_mock), \
|
||||
patch('salt.modules.pkgin._check_pkgin', pkgin__check_pkgin_mock), \
|
||||
patch.dict(pkgin.__salt__, {'cmd.run': pkgin_search_cmd}):
|
||||
self.assertEqual(pkgin.latest_version('somepkg'), '1.2')
|
||||
|
||||
'''
|
||||
Test getting the latest version of a bogus package
|
||||
'''
|
||||
|
|
Loading…
Add table
Reference in a new issue