Merge pull request #44822 from frogunder/pkg_latestversion

add pkg_latest_version test
This commit is contained in:
Nicole Thomas 2018-01-16 09:16:53 -05:00 committed by GitHub
commit de080983e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -326,3 +326,25 @@ class PkgModuleTest(ModuleCase, SaltReturnAssertsMixin):
self.assertNotEqual(ret, {})
if 'changes' in ret:
self.assertNotEqual(ret['changes'], {})
@destructiveTest
@skipIf(salt.utils.is_windows(), 'minion is windows')
@skipIf(salt.utils.is_darwin(), 'minion is mac')
def test_pkg_latest_version(self):
'''
check that pkg.latest_version returns the latest version of the uninstalled package (it does not install the package, just checking the version)
'''
grains = self.run_function('grains.items')
cmd_info = self.run_function('pkg.info_installed', ['htop'])
if cmd_info != 'ERROR: package htop is not installed':
cmd_remove = self.run_function('pkg.remove', ['htop'])
if grains['os_family'] == 'RedHat':
cmd_htop = self.run_function('cmd.run', ['yum list htop'])
elif grains['os_family'] == 'Debian':
cmd_htop = self.run_function('cmd.run', ['apt list htop'])
elif grains['os_family'] == 'Arch':
cmd_htop = self.run_function('cmd.run', ['pacman -Si htop'])
elif grains['os_family'] == 'Suse':
cmd_htop = self.run_function('cmd.run', ['zypper info htop'])
pkg_latest = self.run_function('pkg.latest_version', ['htop'])
self.assertIn(pkg_latest, cmd_htop)