From 846bfbf378d85f224af8f29d3042bd7b490da768 Mon Sep 17 00:00:00 2001 From: Trishna Guha Date: Fri, 9 Mar 2018 17:47:14 +0530 Subject: [PATCH] add nxos_snapshot test for missing required param (#37248) Signed-off-by: Trishna Guha (cherry picked from commit 2501834c422f1b7a1349003fed33fa9a04e135f5) --- .../modules/network/nxos/nxos_snapshot.py | 1 + .../nxos_snapshot/tests/common/sanity.yaml | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/ansible/modules/network/nxos/nxos_snapshot.py b/lib/ansible/modules/network/nxos/nxos_snapshot.py index b989a7bfe9c..0f56328bc13 100644 --- a/lib/ansible/modules/network/nxos/nxos_snapshot.py +++ b/lib/ansible/modules/network/nxos/nxos_snapshot.py @@ -359,6 +359,7 @@ def main(): ("action", "delete", ["snapshot_name"])] module = AnsibleModule(argument_spec=argument_spec, + required_if=required_if, supports_check_mode=True) warnings = list() diff --git a/test/integration/targets/nxos_snapshot/tests/common/sanity.yaml b/test/integration/targets/nxos_snapshot/tests/common/sanity.yaml index 040e77fc269..cb4595caa11 100644 --- a/test/integration/targets/nxos_snapshot/tests/common/sanity.yaml +++ b/test/integration/targets/nxos_snapshot/tests/common/sanity.yaml @@ -34,6 +34,22 @@ path: '.' provider: "{{ connection }}" + - name: FAIL compare snapshots + nxos_snapshot: + action: compare + snapshot1: test_snapshot1 + snapshot2: test_snapshot2 + compare_option: summary + path: '.' + provider: "{{ connection }}" + register: result + ignore_errors: yes + + - assert: + that: + - 'result.failed == True' + - '"action is compare but all of the following are missing: comparison_results_file" in result.msg' + when: snapshot_run always: