mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 05:40:23 -07:00
- Fix to return error message back to the module. (#31035)
This commit is contained in:
parent
bedfd0a5a4
commit
916e6be888
3 changed files with 48 additions and 8 deletions
|
@ -42,12 +42,42 @@ class TestNxosBannerModule(TestNxosModule):
|
|||
def load_fixtures(self, commands=None, device=''):
|
||||
self.load_config.return_value = dict(diff=None, session='session')
|
||||
|
||||
def test_nxos_banner_create(self):
|
||||
def test_nxos_banner_exec_create(self):
|
||||
set_module_args(dict(banner='exec', text='test\nbanner\nstring'))
|
||||
commands = ['banner exec @\ntest\nbanner\nstring\n@']
|
||||
self.run_commands.return_value = commands
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_nxos_banner_remove(self):
|
||||
def test_nxos_banner_exec_remove(self):
|
||||
set_module_args(dict(banner='exec', state='absent'))
|
||||
commands = ['no banner exec']
|
||||
self.run_commands.return_value = commands
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_nxos_banner_exec_fail_create(self):
|
||||
set_module_args(dict(banner='exec', text='test\nbanner\nstring'))
|
||||
commands = ['banner exec @\ntest\nbanner\nstring\n@']
|
||||
err_rsp = ['Invalid command']
|
||||
self.run_commands.return_value = err_rsp
|
||||
result = self.execute_module(failed=True, changed=True)
|
||||
self.assertEqual(result['msg'], 'banner: exec may not be supported on this platform. Possible values are : exec | motd')
|
||||
|
||||
def test_nxos_banner_exec_fail_remove(self):
|
||||
set_module_args(dict(banner='exec', state='absent'))
|
||||
commands = ['no banner exec']
|
||||
err_rsp = ['Invalid command']
|
||||
self.run_commands.return_value = err_rsp
|
||||
result = self.execute_module(failed=True, changed=True)
|
||||
self.assertEqual(result['msg'], 'banner: exec may not be supported on this platform. Possible values are : exec | motd')
|
||||
|
||||
def test_nxos_banner_motd_create(self):
|
||||
set_module_args(dict(banner='motd', text='test\nbanner\nstring'))
|
||||
commands = ['banner motd @\ntest\nbanner\nstring\n@']
|
||||
self.run_commands.return_value = commands
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_nxos_banner_motd_remove(self):
|
||||
set_module_args(dict(banner='motd', state='absent'))
|
||||
commands = ['no banner motd']
|
||||
self.run_commands.return_value = commands
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue