Add pkg.latest_version windows test

This commit is contained in:
Ch3LL 2018-05-15 16:20:55 -04:00
parent a07a8906a0
commit a8981024de
No known key found for this signature in database
GPG Key ID: 132B55A7C13EFA73

View File

@ -337,23 +337,34 @@ class PkgModuleTest(ModuleCase, SaltReturnAssertsMixin):
self.assertNotEqual(ret['changes'], {}) self.assertNotEqual(ret['changes'], {})
@destructiveTest @destructiveTest
@skipIf(salt.utils.is_windows(), 'minion is windows')
@skipIf(salt.utils.is_darwin(), 'minion is mac') @skipIf(salt.utils.is_darwin(), 'minion is mac')
def test_pkg_latest_version(self): 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) 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') grains = self.run_function('grains.items')
cmd_info = self.run_function('pkg.info_installed', ['htop']) remove = False
if cmd_info != 'ERROR: package htop is not installed': if salt.utils.is_windows():
cmd_remove = self.run_function('pkg.remove', ['htop']) cmd_info = self.run_function('pkg.version', [self.pkg])
remove = False if cmd_info == '' else True
else:
cmd_info = self.run_function('pkg.info_installed', [self.pkg])
if cmd_info != 'ERROR: package {0} is not installed'.format(self.pkg):
remove = True
# remove package if its installed
if remove:
cmd_remove = self.run_function('pkg.remove', [self.pkg])
if grains['os_family'] == 'RedHat': if grains['os_family'] == 'RedHat':
cmd_htop = self.run_function('cmd.run', ['yum list htop']) cmd_pkg = self.run_function('cmd.run', ['yum list {0}'.format(self.pkg)])
elif salt.utils.is_windows():
cmd_pkg = self.run_function('pkg.list_available', [self.pkg])
elif grains['os_family'] == 'Debian': elif grains['os_family'] == 'Debian':
cmd_htop = self.run_function('cmd.run', ['apt list htop']) cmd_pkg = self.run_function('cmd.run', ['apt list {0}'.format(self.pkg)])
elif grains['os_family'] == 'Arch': elif grains['os_family'] == 'Arch':
cmd_htop = self.run_function('cmd.run', ['pacman -Si htop']) cmd_pkg = self.run_function('cmd.run', ['pacman -Si {0}'.format(self.pkg)])
elif grains['os_family'] == 'Suse': elif grains['os_family'] == 'Suse':
cmd_htop = self.run_function('cmd.run', ['zypper info htop']) cmd_pkg = self.run_function('cmd.run', ['zypper info {0}'.format(self.pkg)])
pkg_latest = self.run_function('pkg.latest_version', ['htop']) pkg_latest = self.run_function('pkg.latest_version', [self.pkg])
self.assertIn(pkg_latest, cmd_htop) self.assertIn(pkg_latest, cmd_pkg)