diff options
author | David Shrewsbury <Shrews@users.noreply.github.com> | 2021-05-04 17:39:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-04 17:39:04 +0200 |
commit | 244bf9c64055e4516ec3119353290aa99ed4faab (patch) | |
tree | dec2240236fc38529f7a46af0bca3e6ae19e9afa /test/integration/targets/lookup_vars/tasks | |
parent | dont specify default for port, allow ssh/config (#74526) (diff) | |
download | ansible-244bf9c64055e4516ec3119353290aa99ed4faab.tar.xz ansible-244bf9c64055e4516ec3119353290aa99ed4faab.zip |
[coverage] improve test coverage for vars lookup (#74546)
Diffstat (limited to 'test/integration/targets/lookup_vars/tasks')
-rw-r--r-- | test/integration/targets/lookup_vars/tasks/main.yml | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/integration/targets/lookup_vars/tasks/main.yml b/test/integration/targets/lookup_vars/tasks/main.yml index f24d8657ad..57b05b8f23 100644 --- a/test/integration/targets/lookup_vars/tasks/main.yml +++ b/test/integration/targets/lookup_vars/tasks/main.yml @@ -14,3 +14,43 @@ that: - 'var_host_info[0] == ansible_host' - 'var_host_info[1] == ansible_connection' + +- block: + - name: EXPECTED FAILURE - test invalid var + debug: + var: '{{ lookup("vars", "doesnotexist") }}' + + - fail: + msg: "should not get here" + + rescue: + - assert: + that: + - ansible_failed_task.name == "EXPECTED FAILURE - test invalid var" + - expected in ansible_failed_result.msg + vars: + expected: "No variable found with this name: doesnotexist" + +- block: + - name: EXPECTED FAILURE - test invalid var type + debug: + var: '{{ lookup("vars", 42) }}' + + - fail: + msg: "should not get here" + + rescue: + - assert: + that: + - ansible_failed_task.name == "EXPECTED FAILURE - test invalid var type" + - expected in ansible_failed_result.msg + vars: + expected: "Invalid setting identifier, \"42\" is not a string" + +- name: test default + set_fact: + expected_default_var: '{{ lookup("vars", "doesnotexist", default="some text") }}' + +- assert: + that: + - expected_default_var == "some text" |