Skip to content

Commit fa70d42

Browse files
committed
Fix tests.
1 parent 2203467 commit fa70d42

File tree

26 files changed

+132
-123
lines changed

26 files changed

+132
-123
lines changed

tests/integration/targets/consul/tasks/consul_binding_rule.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
that:
3434
- result is changed
3535
- result.binding_rule.AuthMethod == 'test'
36-
- result.binding.Description == 'test-binding: my description'
36+
- "result.binding_rule.Description == 'test-binding: my description'"
3737
- result.operation == 'create'
3838

3939
- name: Update a binding rule
@@ -46,7 +46,7 @@
4646
- assert:
4747
that:
4848
- result is changed
49-
- result.binding.Description == 'test-binding: my description'
49+
- "result.binding_rule.Description == 'test-binding: my description'"
5050
- result.operation == 'update'
5151

5252
- name: Update a binding rule (noop)
@@ -58,7 +58,7 @@
5858
- assert:
5959
that:
6060
- result is not changed
61-
- result.binding.Description == 'test-binding: my description'
61+
- "result.binding_rule.Description == 'test-binding: my description'"
6262
- result.operation is not defined
6363

6464
- name: Delete a binding rule

tests/integration/targets/consul/tasks/consul_token.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
- assert:
2323
that:
2424
- simple_create_result is changed
25-
- simple_create_result.token.AccessorID
25+
- simple_create_result.token.AccessorID is truthy
2626
- simple_create_result.operation == 'create'
2727

2828
- name: Create token
@@ -84,5 +84,5 @@
8484
- assert:
8585
that:
8686
- result is changed
87-
- not result.token
87+
- result.token is falsy
8888
- result.operation == 'remove'

tests/integration/targets/deploy_helper/tasks/main.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,12 @@
123123
register: releases_path
124124
- stat: path={{ deploy_helper.shared_path }}
125125
register: shared_path
126+
when: deploy_helper.shared_path is truthy
126127
- name: Assert State=present with shared_path set to False
127128
assert:
128129
that:
129130
- "releases_path.stat.exists"
130-
- "not shared_path.stat.exists"
131+
- "deploy_helper.shared_path is falsy or not shared_path.stat.exists"
131132

132133
# Setup older releases for tests
133134
- file: path={{ deploy_helper.releases_path }}/{{ item }} state=directory

tests/integration/targets/filter_accumulate/tasks/main.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@
3030
assert:
3131
that:
3232
- integer_result is failed
33-
- integer_result.msg is match('Invalid value type.*')
33+
- integer_result.msg is search('Invalid value type')
3434
- non_uniform_list_result is failed
35-
- non_uniform_list_result.msg is match('Unexpected templating type error.*can only concatenate str.*')
35+
- non_uniform_list_result.msg is search('can only concatenate str')

tests/integration/targets/filter_counter/tasks/main.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
assert:
2727
that:
2828
- res is failed
29-
- res.msg is match('Argument for community.general.counter must be a sequence')
29+
- res.msg is search('Argument for community.general.counter must be a sequence')
3030

3131
- name: test fail element not hashable
3232
debug:
@@ -38,4 +38,4 @@
3838
assert:
3939
that:
4040
- res is failed
41-
- res.msg is match('community.general.counter needs a sequence with hashable elements')
41+
- res.msg is search('community.general.counter needs a sequence with hashable elements')

tests/integration/targets/filter_from_csv/tasks/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@
5151
assert:
5252
that:
5353
- _invalid_csv_strict_true is failed
54-
- _invalid_csv_strict_true.msg is match('Unable to process file:.*')
54+
- _invalid_csv_strict_true.msg is search('Unable to process file:.*')

tests/integration/targets/filter_groupby_as_dict/tasks/main.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
- assert:
1818
that:
19-
- result.msg == 'Input is not a sequence'
19+
- result.msg is search('Input is not a sequence')
2020

2121
- name: 'Test error: list element not a mapping'
2222
set_fact:
@@ -26,7 +26,7 @@
2626

2727
- assert:
2828
that:
29-
- "result.msg == 'Sequence element #0 is not a mapping'"
29+
- "result.msg is search('Sequence element #0 is not a mapping')"
3030

3131
- name: 'Test error: list element does not have attribute'
3232
set_fact:
@@ -36,7 +36,7 @@
3636

3737
- assert:
3838
that:
39-
- "result.msg == 'Attribute not contained in element #1 of sequence'"
39+
- "result.msg is search('Attribute not contained in element #1 of sequence')"
4040

4141
- name: 'Test error: attribute collision'
4242
set_fact:
@@ -46,4 +46,4 @@
4646

4747
- assert:
4848
that:
49-
- result.msg == "Multiple sequence entries have attribute value 'a'" or result.msg == "Multiple sequence entries have attribute value u'a'"
49+
- result.msg is search("Multiple sequence entries have attribute value u?'a'")

tests/integration/targets/filter_hashids/tasks/main.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
- name: Register result of invalid salt
3333
debug:
34-
var: "invalid_input | community.general.hashids_encode(salt=10)"
34+
var: "single_int | community.general.hashids_encode(salt=10)"
3535
register: invalid_salt_message
3636
ignore_errors: true
3737

@@ -42,7 +42,7 @@
4242

4343
- name: Register result of invalid alphabet
4444
debug:
45-
var: "invalid_input | community.general.hashids_encode(alphabet='abc')"
45+
var: "single_int | community.general.hashids_encode(alphabet='abc')"
4646
register: invalid_alphabet_message
4747
ignore_errors: true
4848

@@ -53,7 +53,7 @@
5353

5454
- name: Register result of invalid min_length
5555
debug:
56-
var: "invalid_input | community.general.hashids_encode(min_length='foo')"
56+
var: "single_int | community.general.hashids_encode(min_length='foo')"
5757
register: invalid_min_length_message
5858
ignore_errors: true
5959

tests/integration/targets/filter_keep_keys/tasks/tests.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
- name: Debug ansible_version
77
ansible.builtin.debug:
88
var: ansible_version
9-
when: not quite_test | d(true) | bool
9+
when: not (quiet_test | default(true) | bool)
1010
tags: ansible_version
1111

1212
- name: Tests
@@ -19,13 +19,13 @@
1919
fail_msg: |
2020
[ERR] result:
2121
{{ result | to_yaml }}
22-
quiet: "{{ quiet_test | d(true) | bool }}"
22+
quiet: "{{ quiet_test | default(true) | bool }}"
2323
loop: "{{ tests | subelements('group') }}"
2424
loop_control:
2525
loop_var: i
26-
label: "{{ i.1.mp | d('default') }}: {{ i.1.tt }}"
26+
label: "{{ i.1.mp | default('default') }}: {{ i.1.tt }}"
2727
vars:
2828
input: "{{ i.0.input }}"
2929
target: "{{ i.1.tt }}"
30-
mp: "{{ i.1.mp | d('default') }}"
30+
mp: "{{ i.1.mp | default('default') }}"
3131
result: "{{ lookup('template', i.0.template) }}"

tests/integration/targets/filter_lists_mergeby/tasks/lists_mergeby_2-10.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
{{ my_list|to_nice_yaml|indent(2) }}
1717
my_list|difference(result101):
1818
{{ my_list|difference(result101)|to_nice_yaml|indent(2) }}
19-
when: debug_test|d(false)|bool
19+
when: debug_test|default(false)|bool
2020
- name: Merge 2 lists by attribute name. list_merge='keep'. assert
2121
assert:
2222
that: my_list | difference(result101) | length == 0
@@ -35,7 +35,7 @@
3535
{{ my_list|to_nice_yaml|indent(2) }}
3636
my_list|difference(result102):
3737
{{ my_list|difference(result102)|to_nice_yaml|indent(2) }}
38-
when: debug_test|d(false)|bool
38+
when: debug_test|default(false)|bool
3939
- name: Merge 2 lists by attribute name. list_merge='append'. assert
4040
assert:
4141
that: my_list | difference(result102) | length == 0
@@ -54,7 +54,7 @@
5454
{{ my_list|to_nice_yaml|indent(2) }}
5555
my_list|difference(result103):
5656
{{ my_list|difference(result103)|to_nice_yaml|indent(2) }}
57-
when: debug_test|d(false)|bool
57+
when: debug_test|default(false)|bool
5858
- name: Merge 2 lists by attribute name. list_merge='prepend'. assert
5959
assert:
6060
that: my_list | difference(result103) | length == 0
@@ -73,7 +73,7 @@
7373
{{ my_list|to_nice_yaml|indent(2) }}
7474
my_list|difference(result104):
7575
{{ my_list|difference(result104)|to_nice_yaml|indent(2) }}
76-
when: debug_test|d(false)|bool
76+
when: debug_test|default(false)|bool
7777
- name: Merge 2 lists by attribute name. list_merge='append_rp'. assert
7878
assert:
7979
that: my_list | difference(result104) | length == 0
@@ -92,7 +92,7 @@
9292
{{ my_list|to_nice_yaml|indent(2) }}
9393
my_list|difference(result105):
9494
{{ my_list|difference(result105)|to_nice_yaml|indent(2) }}
95-
when: debug_test|d(false)|bool
95+
when: debug_test|default(false)|bool
9696
- name: Merge 2 lists by attribute name. list_merge='prepend_rp'. assert
9797
assert:
9898
that: my_list | difference(result105) | length == 0
@@ -115,7 +115,7 @@
115115
{{ my_list|to_nice_yaml|indent(2) }}
116116
my_list|difference(result200):
117117
{{ my_list|difference(result200)|to_nice_yaml|indent(2) }}
118-
when: debug_test|d(false)|bool
118+
when: debug_test|default(false)|bool
119119
- name: Merge by name. recursive=True list_merge='append_rp'. assert
120120
assert:
121121
that: my_list | difference(result200) | length == 0
@@ -136,7 +136,7 @@
136136
{{ my_list|to_nice_yaml|indent(2) }}
137137
my_list|difference(result201):
138138
{{ my_list|difference(result201)|to_nice_yaml|indent(2) }}
139-
when: debug_test|d(false)|bool
139+
when: debug_test|default(false)|bool
140140
- name: Merge by name. recursive=False list_merge='append_rp'. assert
141141
assert:
142142
that: my_list | difference(result201) | length == 0

tests/integration/targets/filter_lists_mergeby/tasks/lists_mergeby_default.yml

+11-11
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
- name: Debug ansible_version
77
debug:
88
var: ansible_version
9-
when: debug_test|d(false)|bool
9+
when: debug_test|default(false)|bool
1010
tags: t0
1111

1212
- name: 1. Test lists merged by attribute name
1313
block:
1414
- name: Test lists merged by attribute name debug
1515
debug:
1616
msg: "{{ list1 | community.general.lists_mergeby(list2, 'name') }}"
17-
when: debug_test|d(false)|bool
17+
when: debug_test|default(false)|bool
1818
- name: Test lists merged by attribute name assert
1919
assert:
2020
that:
@@ -27,7 +27,7 @@
2727
- name: Test list1 empty debug
2828
debug:
2929
msg: "{{ [] | community.general.lists_mergeby(list2, 'name') }}"
30-
when: debug_test|d(false)|bool
30+
when: debug_test|default(false)|bool
3131
- name: Test list1 empty assert
3232
assert:
3333
that:
@@ -40,7 +40,7 @@
4040
- name: Test all lists empty debug
4141
debug:
4242
msg: "{{ [] | community.general.lists_mergeby([], 'name') }}"
43-
when: debug_test|d(false)|bool
43+
when: debug_test|default(false)|bool
4444
- name: Test all lists empty assert
4545
assert:
4646
that:
@@ -58,7 +58,7 @@
5858
- name: First argument must be list debug
5959
debug:
6060
var: my_list
61-
when: debug_test|d(false)|bool
61+
when: debug_test|default(false)|bool
6262
- name: First argument must be list assert
6363
assert:
6464
that:
@@ -76,7 +76,7 @@
7676
- name: Second argument must be list set debug
7777
debug:
7878
var: my_list
79-
when: debug_test|d(false)|bool
79+
when: debug_test|default(false)|bool
8080
- name: Second argument must be list set assert
8181
assert:
8282
that:
@@ -94,7 +94,7 @@
9494
- name: First arguments after the lists must be string debug
9595
debug:
9696
var: my_list
97-
when: debug_test|d(false)|bool
97+
when: debug_test|default(false)|bool
9898
- name: First arguments after the lists must be string assert
9999
assert:
100100
that:
@@ -112,7 +112,7 @@
112112
- name: Elements of list must be dictionaries debug
113113
debug:
114114
var: my_list
115-
when: debug_test|d(false)|bool
115+
when: debug_test|default(false)|bool
116116
- name: Elements of list must be dictionaries assert
117117
assert:
118118
that:
@@ -128,7 +128,7 @@
128128
- name: Merge 3 lists by attribute name. 1 list in params. debug
129129
debug:
130130
var: my_list
131-
when: debug_test|d(false)|bool
131+
when: debug_test|default(false)|bool
132132
- name: Merge 3 lists by attribute name. 1 list in params. assert
133133
assert:
134134
that: my_list | difference(result1) | length == 0
@@ -142,7 +142,7 @@
142142
- name: Merge 3 lists by attribute name. No list in the params. debug
143143
debug:
144144
var: my_list
145-
when: debug_test|d(false)|bool
145+
when: debug_test|default(false)|bool
146146
- name: Merge 3 lists by attribute name. No list in the params. asset
147147
assert:
148148
that: my_list | difference(result1) | length == 0
@@ -162,7 +162,7 @@
162162
{{ my_list|to_nice_yaml|indent(2) }}
163163
my_list|difference(result100):
164164
{{ my_list|difference(result100)|to_nice_yaml|indent(2) }}
165-
when: debug_test|d(false)|bool
165+
when: debug_test|default(false)|bool
166166
- name: Merge 2 lists by attribute name. list_merge='replace'. assert
167167
assert:
168168
that: my_list | difference(result100) | length == 0

tests/integration/targets/filter_random_mac/tasks/main.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
assert:
2020
that:
2121
- _bad_random_mac_filter is failed
22-
- "_bad_random_mac_filter.msg is match('Invalid value type (.*int.*) for random_mac .*')"
22+
- "_bad_random_mac_filter.msg is search('Invalid value type (.*int.*) for random_mac .*')"
2323

2424
- name: Test random_mac filter bad argument value
2525
debug:
@@ -31,7 +31,7 @@
3131
assert:
3232
that:
3333
- _bad_random_mac_filter is failed
34-
- "_bad_random_mac_filter.msg is match('Invalid value (.*) for random_mac: .* not hexa byte')"
34+
- "_bad_random_mac_filter.msg is search('Invalid value (.*) for random_mac: .* not hexa byte')"
3535

3636
- name: Test random_mac filter prefix too big
3737
debug:
@@ -43,7 +43,7 @@
4343
assert:
4444
that:
4545
- _bad_random_mac_filter is failed
46-
- "_bad_random_mac_filter.msg is match('Invalid value (.*) for random_mac: 5 colon.* separated items max')"
46+
- "_bad_random_mac_filter.msg is search('Invalid value (.*) for random_mac: 5 colon.* separated items max')"
4747

4848
- name: Verify random_mac filter
4949
assert:

tests/integration/targets/filter_remove_keys/tasks/tests.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
- name: Debug ansible_version
77
ansible.builtin.debug:
88
var: ansible_version
9-
when: not quite_test | d(true) | bool
9+
when: not (quiet_test | default(true) | bool)
1010
tags: ansible_version
1111

1212
- name: Tests
@@ -19,13 +19,13 @@
1919
fail_msg: |
2020
[ERR] result:
2121
{{ result | to_yaml }}
22-
quiet: "{{ quiet_test | d(true) | bool }}"
22+
quiet: "{{ quiet_test | default(true) | bool }}"
2323
loop: "{{ tests | subelements('group') }}"
2424
loop_control:
2525
loop_var: i
26-
label: "{{ i.1.mp | d('default') }}: {{ i.1.tt }}"
26+
label: "{{ i.1.mp | default('default') }}: {{ i.1.tt }}"
2727
vars:
2828
input: "{{ i.0.input }}"
2929
target: "{{ i.1.tt }}"
30-
mp: "{{ i.1.mp | d('default') }}"
30+
mp: "{{ i.1.mp | default('default') }}"
3131
result: "{{ lookup('template', i.0.template) }}"

0 commit comments

Comments
 (0)