diff options
Diffstat (limited to 'test/integration')
-rw-r--r-- | test/integration/targets/service/tasks/tests.yml | 29 | ||||
-rw-r--r-- | test/integration/targets/systemd/defaults/main.yml | 1 | ||||
-rw-r--r-- | test/integration/targets/systemd/tasks/main.yml | 25 |
3 files changed, 55 insertions, 0 deletions
diff --git a/test/integration/targets/service/tasks/tests.yml b/test/integration/targets/service/tasks/tests.yml index fd66918b07..de66bf5ca7 100644 --- a/test/integration/targets/service/tasks/tests.yml +++ b/test/integration/targets/service/tasks/tests.yml @@ -194,3 +194,32 @@ that: - "remove_result.path == '/usr/sbin/ansible_test_service'" - "remove_result.state == 'absent'" + +- name: the module must fail when a service is not found + service: + name: 'nonexisting' + state: stopped + register: result + ignore_errors: yes + when: ansible_distribution != 'FreeBSD' + +- assert: + that: + - result is failed + - result is search("Could not find the requested service nonexisting") + when: ansible_distribution != 'FreeBSD' + +- name: the module must fail in check_mode as well when a service is not found + service: + name: 'nonexisting' + state: stopped + register: result + check_mode: yes + ignore_errors: yes + when: ansible_distribution != 'FreeBSD' + +- assert: + that: + - result is failed + - result is search("Could not find the requested service nonexisting") + when: ansible_distribution != 'FreeBSD' diff --git a/test/integration/targets/systemd/defaults/main.yml b/test/integration/targets/systemd/defaults/main.yml new file mode 100644 index 0000000000..33063b86d9 --- /dev/null +++ b/test/integration/targets/systemd/defaults/main.yml @@ -0,0 +1 @@ +fake_service: nonexisting diff --git a/test/integration/targets/systemd/tasks/main.yml b/test/integration/targets/systemd/tasks/main.yml index a3078540ec..282988b356 100644 --- a/test/integration/targets/systemd/tasks/main.yml +++ b/test/integration/targets/systemd/tasks/main.yml @@ -47,4 +47,29 @@ - 'not systemd_test0.changed' - 'systemd_test0.state == "started"' + - name: the module must fail when a service is not found + systemd: + name: '{{ fake_service }}' + state: stopped + register: result + ignore_errors: yes + + - assert: + that: + - result is failed + - result is search("Could not find the requested service {{ fake_service }}") + + - name: the module must fail in check_mode as well when a service is not found + systemd: + name: '{{ fake_service }}' + state: stopped + register: result + check_mode: yes + ignore_errors: yes + + - assert: + that: + - result is failed + - result is search("Could not find the requested service {{ fake_service }}") + when: 'systemctl_check.rc == 0' |