From 40b337fbf46d27d4e8bf545c1dc2c94fb599c179 Mon Sep 17 00:00:00 2001 From: Harsh Jain Date: Thu, 30 Apr 2020 13:38:36 +0530 Subject: [PATCH] Add a test for downing non existent profile --- tests/playbooks/tests_states.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/playbooks/tests_states.yml b/tests/playbooks/tests_states.yml index a752ba1..8edbf8f 100644 --- a/tests/playbooks/tests_states.yml +++ b/tests/playbooks/tests_states.yml @@ -47,3 +47,31 @@ state: down - include_tasks: tasks/assert_device_absent.yml - include_tasks: tasks/assert_profile_absent.yml + + # test case (downing a non existent profile) + # I can set down and remove a non existent profile + # This will be rescued until issue 188 is fixed + - name: Verify that the play fails with the expected error message + block: + - name: Set down non existent profile + include_role: + name: linux-system-roles.network + vars: + network_connections: + - name: non_existent + state: down + persistent_state: absent + + - name: 'UNREACH' + set_fact: + __network_test_failed: false + + rescue: + - name: Role has failed when it should have + set_fact: + __network_test_failed: true + + always: + - assert: + that: __network_test_failed + fail_msg: "The role did not fail when it should have"