mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-03-22 05:09:12 +00:00
feat: two integration tests added
Signed-off-by: Fiehe Christoph <c.fiehe@eurodata.de>
This commit is contained in:
parent
314d75d72c
commit
7384b2b4d6
2 changed files with 81 additions and 0 deletions
|
|
@ -44,6 +44,62 @@
|
|||
vars:
|
||||
merged_dict: "{{ lookup('community.general.merge_variables', '^.+__merge_dict$') }}"
|
||||
|
||||
- name: Test shallow dict merge with 'list_merge=append' and 'dedup'
|
||||
block:
|
||||
- name: Print the merged dict
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ merged_dict }}"
|
||||
|
||||
- name: Validate the merged dict
|
||||
ansible.builtin.assert:
|
||||
that: "merged_dict == expected_dict"
|
||||
vars:
|
||||
expected_dict:
|
||||
a: "{{ testdict4__test['a'] }}"
|
||||
b:
|
||||
- 3
|
||||
- 4
|
||||
- "5": value
|
||||
- 1
|
||||
- 2
|
||||
vars:
|
||||
merged_dict: "{{
|
||||
lookup(
|
||||
'community.general.merge_variables', '__test', pattern_type='suffix', override='ignore',
|
||||
dict_merge='shallow', list_merge='prepend', list_transformations=['dedup']) }}"
|
||||
|
||||
- name: Test deep dict merge with 'list_merge=prepend' and 'dedup' with 'keep=last'
|
||||
block:
|
||||
- name: Print the merged dict
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ merged_dict }}"
|
||||
|
||||
- name: Validate the merged dict
|
||||
ansible.builtin.assert:
|
||||
that: "merged_dict == expected_dict"
|
||||
vars:
|
||||
expected_dict:
|
||||
a:
|
||||
a:
|
||||
x: low_value
|
||||
y: high_value
|
||||
list:
|
||||
- high_value
|
||||
- low_value
|
||||
z: high_value
|
||||
b:
|
||||
- 4
|
||||
- "5": value
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
vars:
|
||||
merged_dict: "{{
|
||||
lookup(
|
||||
'community.general.merge_variables', '__test', pattern_type='suffix', override='ignore',
|
||||
dict_merge='deep', list_merge='prepend',
|
||||
list_transformations=[{'name': 'dedup', 'options': {'keep': 'last'}}]) }}"
|
||||
|
||||
# Test the behavior when no results are found
|
||||
- name: Test merge without results
|
||||
block:
|
||||
|
|
|
|||
|
|
@ -21,6 +21,31 @@ testdict2__merge_dict:
|
|||
list_item:
|
||||
- test2
|
||||
|
||||
testdict3__test:
|
||||
a:
|
||||
a:
|
||||
x: low_value
|
||||
y: low_value
|
||||
list:
|
||||
- low_value
|
||||
b:
|
||||
- 1
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
testdict4__test:
|
||||
a:
|
||||
a:
|
||||
y: high_value
|
||||
z: high_value
|
||||
list:
|
||||
- high_value
|
||||
b:
|
||||
- 3
|
||||
- 4
|
||||
- 4
|
||||
- "5": value
|
||||
|
||||
override_warn_init:
|
||||
key_to_override: Initial value
|
||||
override__override_warn:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue