diff --git a/test/integration/roles/test_failed_when/tasks/main.yml b/test/integration/roles/test_failed_when/tasks/main.yml index 3492422e43..a69cef74cf 100644 --- a/test/integration/roles/test_failed_when/tasks/main.yml +++ b/test/integration/roles/test_failed_when/tasks/main.yml @@ -16,13 +16,54 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . -- name: Test failed_when behavior but catch it. - command: /bin/true - failed_when: 2 != 3 - register: failed +- name: command rc 0 failed_when_result undef + shell: exit 0 ignore_errors: True + register: result -- name: Assert that failed_when is true. - assert: +- assert: that: - - "failed.failed_when_result == True" \ No newline at end of file + - "'failed' not in result" + +- name: command rc 0 failed_when_result False + shell: exit 0 + failed_when: false + ignore_errors: true + register: result + +- assert: + that: + - "'failed' in result and not result.failed" + - "'failed_when_result' in result and not result.failed_when_result" + +- name: command rc 1 failed_when_result True + shell: exit 1 + failed_when: true + ignore_errors: true + register: result + +- assert: + that: + - "'failed' in result and result.failed" + - "'failed_when_result' in result and result.failed_when_result" + +- name: command rc 1 failed_when_result undef + shell: exit 1 + ignore_errors: true + register: result + +- assert: + that: + - "'failed' not in result" + +- name: command rc 1 failed_when_result False + shell: exit 1 + failed_when: false + ignore_errors: true + register: result + +- assert: + that: + - "'failed' in result and not result.failed" + - "'failed_when_result' in result and not result.failed_when_result" +