coverage for lookup_config (#68566)

Signed-off-by: Rick Elrod <rick@elrod.me>
pull/68598/head
Rick Elrod 5 years ago committed by GitHub
parent 2b4ca69bc2
commit 541384e7b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

@ -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'
Loading…
Cancel
Save