diff options
author | Nathaniel Case <this.is@nathanielca.se> | 2017-04-27 11:08:37 -0400 |
---|---|---|
committer | Nathaniel Case <ncase@redhat.com> | 2017-04-27 11:09:38 -0400 |
commit | b4380432f6f490a02423abf7215d88200685ceae (patch) | |
tree | 856e48c87a0308992b21f0404fff0d974d8cdabe /test | |
parent | 126878488f43ec181ccf4d4fa91ae9cd04aee84f (diff) | |
download | ansible-b4380432f6f490a02423abf7215d88200685ceae.tar.gz |
Run `save` inside config mode. (#23977)
* Run `save` before exiting config mode.
* Fix unit tests for `save`
* Allow `save` to be on its own again and introspect success
* Introspecting `compare running` makes this a lot harder.
Move `save` tests to integration tests
(cherry picked from commit fc0bf87c20c394dae7246a75ed29cc50f5ddd5df)
Diffstat (limited to 'test')
-rw-r--r-- | test/integration/targets/vyos_config/tests/cli/save.yaml | 60 | ||||
-rw-r--r-- | test/units/modules/network/vyos/test_vyos_config.py | 9 |
2 files changed, 60 insertions, 9 deletions
diff --git a/test/integration/targets/vyos_config/tests/cli/save.yaml b/test/integration/targets/vyos_config/tests/cli/save.yaml new file mode 100644 index 0000000000..0eeeb80477 --- /dev/null +++ b/test/integration/targets/vyos_config/tests/cli/save.yaml @@ -0,0 +1,60 @@ +--- +- debug: msg="START cli/save.yaml" + +- name: setup + vyos_config: + lines: set system host-name {{ inventory_hostname_short }} + provider: "{{ cli }}" + match: none + +- name: configure hostaname and save + vyos_config: + lines: set system host-name foo + provider: "{{ cli }}" + save: true + register: result + +- assert: + that: + - "result.changed == true" + - "'set system host-name foo' in result.commands" + +- name: configure hostaname and don't save + vyos_config: + lines: set system host-name bar + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == true" + - "'set system host-name bar' in result.commands" + +- name: save config + vyos_config: + save: true + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == true" + +- name: save config again + vyos_config: + save: true + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == false" + +- name: teardown + vyos_config: + lines: set system host-name {{ inventory_hostname_short }} + provider: "{{ cli }}" + match: none + save: true + +- debug: msg="END cli/simple.yaml" diff --git a/test/units/modules/network/vyos/test_vyos_config.py b/test/units/modules/network/vyos/test_vyos_config.py index 6ecd9bc4e4..09dc7a0d2f 100644 --- a/test/units/modules/network/vyos/test_vyos_config.py +++ b/test/units/modules/network/vyos/test_vyos_config.py @@ -73,15 +73,6 @@ class TestVyosConfigModule(TestVyosModule): result = self.execute_module() self.assertIn('__backup__', result) - def test_vyos_config_save(self): - set_module_args(dict(save=True)) - self.execute_module(changed=True) - self.assertEqual(self.run_commands.call_count, 1) - self.assertEqual(self.get_config.call_count, 0) - self.assertEqual(self.load_config.call_count, 0) - args = self.run_commands.call_args[0][1] - self.assertIn('save', args) - def test_vyos_config_lines(self): commands = ['set system host-name foo'] set_module_args(dict(lines=commands)) |