mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
Merge pull request #46248 from garethgreenaway/45325_display_usage_for_runners
[develop] display usage for runners when missing arguments
This commit is contained in:
commit
4df31ac297
@ -384,7 +384,11 @@ class SyncClientMixin(object):
|
||||
|
||||
# Initialize a context for executing the method.
|
||||
with tornado.stack_context.StackContext(self.functions.context_dict.clone):
|
||||
data['return'] = self.functions[fun](*args, **kwargs)
|
||||
func = self.functions[fun]
|
||||
try:
|
||||
data['return'] = func(*args, **kwargs)
|
||||
except TypeError as exc:
|
||||
data['return'] = '\nPassed invalid arguments: {0}\n\nUsage:\n{1}'.format(exc, func.__doc__)
|
||||
try:
|
||||
data['success'] = self.context.get('retcode', 0) == 0
|
||||
except AttributeError:
|
||||
|
@ -34,3 +34,15 @@ class ManageTest(ShellCase):
|
||||
ret = self.run_run_plus('cache.flush', bank='cachetest/runner', key='test_cache')
|
||||
ret = self.run_run_plus('cache.list', bank='cachetest/runner')
|
||||
self.assertNotIn('test_cache', ret['return'])
|
||||
|
||||
def test_cache_invalid(self):
|
||||
'''
|
||||
Store, list, fetch, then flush data
|
||||
'''
|
||||
# Store the data
|
||||
ret = self.run_run_plus(
|
||||
'cache.store',
|
||||
)
|
||||
# Make sure we can see the new key
|
||||
expected = 'Passed invalid arguments:'
|
||||
self.assertIn(expected, ret['return'])
|
||||
|
@ -30,6 +30,14 @@ class ManageTest(ShellCase):
|
||||
self.assertEqual(ret['return'], {})
|
||||
self.assertEqual(ret['out'], [])
|
||||
|
||||
def test_lookup_jid_invalid(self):
|
||||
'''
|
||||
jobs.lookup_jid
|
||||
'''
|
||||
ret = self.run_run_plus('jobs.lookup_jid')
|
||||
expected = 'Passed invalid arguments:'
|
||||
self.assertIn(expected, ret['return'])
|
||||
|
||||
@skipIf(True, 'to be re-enabled when #23623 is merged')
|
||||
def test_list_jobs(self):
|
||||
'''
|
||||
|
@ -25,3 +25,11 @@ class SaltRunnerTest(ShellCase):
|
||||
|
||||
self.assertEqual(out_ret, 'True')
|
||||
self.assertTrue(return_ret)
|
||||
|
||||
def test_salt_cmd_invalid(self):
|
||||
'''
|
||||
test return values of salt.cmd invalid parameters
|
||||
'''
|
||||
ret = self.run_run_plus('salt.cmd')
|
||||
expected = 'Passed invalid arguments:'
|
||||
self.assertIn(expected, ret['return'])
|
||||
|
Loading…
Reference in New Issue
Block a user