diff options
author | Sloane Hertel <19572925+s-hertel@users.noreply.github.com> | 2021-08-30 12:03:42 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-30 12:03:42 -0400 |
commit | e5f6c2d141d9f4e0c3efd22d98eaef0e29a74109 (patch) | |
tree | bf37029186330ee41037b7c4e2bd568783f7dbd0 /test | |
parent | 051a257092200893a0c1732ea07c96d7ff90889e (diff) | |
download | ansible-e5f6c2d141d9f4e0c3efd22d98eaef0e29a74109.tar.gz |
Fix rekey_on_member when key is undefined (#75131)
* Fix rekey_on_member when key is undefined and add a test case
* Add documentation about error handling in filter and test plugin sections
Diffstat (limited to 'test')
4 files changed, 17 insertions, 0 deletions
diff --git a/test/integration/targets/filter_mathstuff/host_vars/localhost.yml b/test/integration/targets/filter_mathstuff/host_vars/localhost.yml new file mode 100644 index 0000000000..1f5a9e0319 --- /dev/null +++ b/test/integration/targets/filter_mathstuff/host_vars/localhost.yml @@ -0,0 +1 @@ +foo: test diff --git a/test/integration/targets/filter_mathstuff/tasks/main.yml b/test/integration/targets/filter_mathstuff/tasks/main.yml index 93a65727f0..019f00e4c2 100644 --- a/test/integration/targets/filter_mathstuff/tasks/main.yml +++ b/test/integration/targets/filter_mathstuff/tasks/main.yml @@ -301,6 +301,18 @@ - rekey_on_member_exc5_res is failed - '"is not unique, cannot correctly turn into dict" in rekey_on_member_exc5_res.msg' +- name: test undefined positional args for rekey_on_member are properly handled + vars: + all_vars: "{{ hostvars[inventory_hostname] }}" + test_var: "{{ all_vars.foo }}" + block: + - include_vars: + file: defined_later.yml + - assert: + that: "test_var == 'test'" + - assert: + that: "rekeyed == {'value': {'test': 'value'}}" + # TODO: For some reason, the coverage tool isn't accounting for the last test # so add another "last test" to fake it... - assert: diff --git a/test/integration/targets/filter_mathstuff/vars/defined_later.yml b/test/integration/targets/filter_mathstuff/vars/defined_later.yml new file mode 100644 index 0000000000..dfb2421b61 --- /dev/null +++ b/test/integration/targets/filter_mathstuff/vars/defined_later.yml @@ -0,0 +1,3 @@ +do_rekey: + - test: value +rekeyed: "{{ do_rekey | rekey_on_member(defined_later) }}" diff --git a/test/integration/targets/filter_mathstuff/vars/main.yml b/test/integration/targets/filter_mathstuff/vars/main.yml new file mode 100644 index 0000000000..bb61e12ee3 --- /dev/null +++ b/test/integration/targets/filter_mathstuff/vars/main.yml @@ -0,0 +1 @@ +defined_later: "{{ test_var }}" |