mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Refactor update
This commit is contained in:
parent
d41e62b1d3
commit
182b80d67e
@ -324,14 +324,9 @@ def update(name):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' softwareupdate.install <update-name>
|
||||
salt '*' softwareupdate.update <update-name>
|
||||
'''
|
||||
try:
|
||||
updates = _get_available()
|
||||
except CommandExecutionError as exc:
|
||||
raise CommandExecutionError(exc)
|
||||
|
||||
if name not in updates:
|
||||
if not update_available(name):
|
||||
raise SaltInvocationError('Update not available: {0}'.format(name))
|
||||
|
||||
try:
|
||||
@ -340,12 +335,7 @@ def update(name):
|
||||
except CommandExecutionError as exc:
|
||||
raise CommandExecutionError(exc)
|
||||
|
||||
try:
|
||||
updates = _get_available()
|
||||
except CommandExecutionError as exc:
|
||||
raise CommandExecutionError(exc)
|
||||
|
||||
return name not in updates
|
||||
return not update_available(name)
|
||||
|
||||
|
||||
def update_available(name):
|
||||
|
@ -113,15 +113,22 @@ class MacSoftwareUpdateModuleTest(integration.ModuleCase):
|
||||
self.assertFalse(self.run_function('softwareupdate.schedule_enabled'))
|
||||
|
||||
@destructiveTest
|
||||
def test_update_all(self):
|
||||
def test_update(self):
|
||||
'''
|
||||
Test softwareupdate.update_all
|
||||
Test softwareupdate.update
|
||||
Test softwareupdate.update_available
|
||||
'''
|
||||
# There's no way to know what the dictionary will contain, so all we can
|
||||
# check is that the return is a dictionary
|
||||
self.assertIsInstance(
|
||||
self.run_function('softwareupdate.update_all'), dict)
|
||||
|
||||
# Test update not available
|
||||
self.assertIn(
|
||||
'Update not available',
|
||||
self.run_function('softwareupdate.update', ['spongebob']))
|
||||
|
||||
@destructiveTest
|
||||
def test_install(self):
|
||||
'''
|
||||
|
Loading…
Reference in New Issue
Block a user