mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
Put tests behind try block
Uninstall firefox in finally Add some log messages
This commit is contained in:
parent
6771659f30
commit
3df091f543
@ -50,13 +50,16 @@ class ChocolateyTest(ModuleCase, SaltReturnAssertsMixin):
|
||||
target = 'firefox'
|
||||
pre_version = '52.0.2'
|
||||
upg_version = '57.0.2'
|
||||
log.debug('Making sure {0} is not installed'.format(target))
|
||||
self.assertFalse(
|
||||
self.run_function('chocolatey.version', [target]))
|
||||
|
||||
try:
|
||||
####################################################
|
||||
# Test `chocolatey.installed`
|
||||
####################################################
|
||||
# Install the package
|
||||
log.debug('Testing chocolatey.installed')
|
||||
ret = self.run_state(
|
||||
'chocolatey.installed',
|
||||
name=target,
|
||||
@ -64,13 +67,15 @@ class ChocolateyTest(ModuleCase, SaltReturnAssertsMixin):
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
||||
# Verify the package is installed
|
||||
log.debug('Verifying install success')
|
||||
ret = self.run_function('chocolatey.version', [target])
|
||||
self.assertEqual(ret, {'Firefox': pre_version})
|
||||
self.assertEqual(ret, {'Firefox': [pre_version]})
|
||||
|
||||
####################################################
|
||||
# Test `chocolatey.upgraded`
|
||||
####################################################
|
||||
# Upgrade the package
|
||||
log.debug('Testing chocolatey.upgraded')
|
||||
ret = self.run_state(
|
||||
'chocolatey.upgraded',
|
||||
name=target,
|
||||
@ -78,17 +83,24 @@ class ChocolateyTest(ModuleCase, SaltReturnAssertsMixin):
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
||||
# Verify the package is upgraded
|
||||
log.debug('Verifying upgrade success')
|
||||
ret = self.run_function('chocolatey.version', [target])
|
||||
self.assertEqual(ret, {'Firefox': upg_version})
|
||||
self.assertEqual(ret, {'Firefox': [upg_version]})
|
||||
|
||||
####################################################
|
||||
# Test `chocolatey.uninstalled`
|
||||
####################################################
|
||||
# uninstall the package
|
||||
log.debug('Testing chocolatey.uninstalled')
|
||||
ret = self.run_state('chocolatey.uninstalled', name=target)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
||||
# Verify the package is uninstalled
|
||||
log.debug('Verifying uninstall success')
|
||||
ret = self.run_function('chocolatey.version', [target])
|
||||
self.assertEqual(ret, {})
|
||||
|
||||
finally:
|
||||
# Always uninstall
|
||||
log.debug('Uninstalling {0}'.format(target))
|
||||
self.run_function('chocolatey.uninstall', [target])
|
||||
|
Loading…
Reference in New Issue
Block a user