summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRick Elrod <rick@elrod.me>2020-03-31 16:57:50 +0200
committerGitHub <noreply@github.com>2020-03-31 16:57:50 +0200
commit541384e7b70e8f0a78d76a7863e56d994f5f4aea (patch)
treeafc58623ebeb1393670b6d7ec32f3f1f3f62c8ba /test
parentAdd notifications to BOTMETA.yml. (diff)
downloadansible-541384e7b70e8f0a78d76a7863e56d994f5f4aea.tar.xz
ansible-541384e7b70e8f0a78d76a7863e56d994f5f4aea.zip
coverage for lookup_config (#68566)
Signed-off-by: Rick Elrod <rick@elrod.me>
Diffstat (limited to 'test')
-rw-r--r--test/integration/targets/lookup_config/aliases3
-rw-r--r--test/integration/targets/lookup_config/tasks/main.yml59
2 files changed, 62 insertions, 0 deletions
diff --git a/test/integration/targets/lookup_config/aliases b/test/integration/targets/lookup_config/aliases
new file mode 100644
index 0000000000..bc987654d9
--- /dev/null
+++ b/test/integration/targets/lookup_config/aliases
@@ -0,0 +1,3 @@
+shippable/posix/group2
+skip/aix
+skip/python2.6 # lookups are controller only, and we no longer support Python 2.6 on the controller
diff --git a/test/integration/targets/lookup_config/tasks/main.yml b/test/integration/targets/lookup_config/tasks/main.yml
new file mode 100644
index 0000000000..be185197b9
--- /dev/null
+++ b/test/integration/targets/lookup_config/tasks/main.yml
@@ -0,0 +1,59 @@
+- name: Verify lookup_config errors with no on_missing (failure expected)
+ set_fact:
+ foo: '{{lookup("config", "THIS_DOES_NOT_EXIST")}}'
+ ignore_errors: yes
+ register: lookup_config_1
+
+- name: Verify lookup_config errors with on_missing=error (failure expected)
+ set_fact:
+ foo: '{{lookup("config", "THIS_DOES_NOT_EXIST", on_missing="error")}}'
+ ignore_errors: yes
+ register: lookup_config_2
+
+- name: Verify lookup_config does not error with on_missing=skip
+ set_fact:
+ lookup3: '{{lookup("config", "THIS_DOES_NOT_EXIST", on_missing="skip")}}'
+ register: lookup_config_3
+
+# TODO: Is there a decent way to check that the warning is actually triggered?
+- name: Verify lookup_config does not error with on_missing=warn (warning expected)
+ set_fact:
+ lookup4: '{{lookup("config", "THIS_DOES_NOT_EXIST", on_missing="warn")}}'
+ register: lookup_config_4
+
+- name: Verify lookup_config errors with invalid on_missing (failure expected)
+ set_fact:
+ foo: '{{lookup("config", "THIS_DOES_NOT_EXIST", on_missing="boo")}}'
+ ignore_errors: yes
+ register: lookup_config_5
+
+- name: Verify lookup_config errors with invalid param type (failure expected)
+ set_fact:
+ foo: '{{lookup("config", 1337)}}'
+ ignore_errors: yes
+ register: lookup_config_6
+
+- name: Verify lookup_config errors with callable arg (failure expected)
+ set_fact:
+ foo: '{{lookup("config", "ConfigManager")}}'
+ ignore_errors: yes
+ register: lookup_config_7
+
+- name: Verify lookup_config
+ assert:
+ that:
+ - '"meow" in lookup("config", "ANSIBLE_COW_WHITELIST")'
+ - lookup_config_1 is failed
+ - '"Unable to find setting" in lookup_config_1.msg'
+ - lookup_config_2 is failed
+ - '"Unable to find setting" in lookup_config_2.msg'
+ - lookup_config_3 is success
+ - 'lookup3|length == 0'
+ - lookup_config_4 is success
+ - 'lookup4|length == 0'
+ - lookup_config_5 is failed
+ - '"must be a string and one of" in lookup_config_5.msg'
+ - lookup_config_6 is failed
+ - '"Invalid setting identifier" in lookup_config_6.msg'
+ - lookup_config_7 is failed
+ - '"Invalid setting" in lookup_config_7.msg'