summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/service/tasks
diff options
context:
space:
mode:
authorAndrew Klychkov <aaklychkov@mail.ru>2020-06-02 17:52:12 +0200
committerGitHub <noreply@github.com>2020-06-02 17:52:12 +0200
commit00ead98595577f110165d2c87c6c5c38c27b4b74 (patch)
tree8fc58fc0e99fd52c95bf19beacca6df3fce0ddc8 /test/integration/targets/service/tasks
parentUpdate plugin_formatter to understand tagged version_added (#69797) (diff)
downloadansible-00ead98595577f110165d2c87c6c5c38c27b4b74.tar.xz
ansible-00ead98595577f110165d2c87c6c5c38c27b4b74.zip
systemd: should fail in check_mode when service not found on host (#68136)
* systemd: should fail in check_mode when service not found on host
Diffstat (limited to 'test/integration/targets/service/tasks')
-rw-r--r--test/integration/targets/service/tasks/tests.yml29
1 files changed, 29 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'