Skip to content

Commit 796e253

Browse files
committed
Fix tests.
1 parent 3d6c5e3 commit 796e253

File tree

15 files changed

+43
-40
lines changed

15 files changed

+43
-40
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_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) }}"

tests/integration/targets/filter_replace_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/kernel_blacklist/tasks/main.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
- orig_stat.stat.size == stat_test_1.stat.size
5252
- orig_stat.stat.checksum == stat_test_1.stat.checksum
5353
- orig_stat.stat.mtime == stat_test_1.stat.mtime
54-
- stat_test_1.stat.checksum == expected_content | checksum
54+
- stat_test_1.stat.checksum == (expected_content | trim + '\n') | checksum
5555
vars:
5656
expected_content: |
5757
# Copyright (c) Ansible Project
@@ -83,7 +83,7 @@
8383
assert:
8484
that:
8585
- bl_test_2 is changed
86-
- slurp_test_2.content|b64decode == content
86+
- slurp_test_2.content|b64decode == (content | trim + '\n')
8787
vars:
8888
content: |
8989
# Copyright (c) Ansible Project
@@ -111,7 +111,7 @@
111111
assert:
112112
that:
113113
- bl_test_3 is changed
114-
- slurp_test_3.content|b64decode == content
114+
- slurp_test_3.content|b64decode == (content | trim + '\n')
115115
vars:
116116
content: |
117117
# Copyright (c) Ansible Project

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@
151151
- result.end_state.config.enabled == ["true"]
152152
- result.end_state.config.algorithm == ["RS256"]
153153
- result.end_state.config.priority == ["140"]
154-
- result.msg == "Realm key testkey would be changed: config.priority ['150'] -> ['140']"
154+
- >-
155+
result.msg == "Realm key testkey would be changed: config.priority ['150'] -> ['140']"
155156
156157
- name: Update custom realm key
157158
community.general.keycloak_realm_key:
@@ -184,7 +185,8 @@
184185
- result.end_state.config.enabled == ["true"]
185186
- result.end_state.config.algorithm == ["RS256"]
186187
- result.end_state.config.priority == ["140"]
187-
- result.msg == "Realm key testkey changed: config.priority ['150'] -> ['140']"
188+
- >-
189+
result.msg == "Realm key testkey changed: config.priority ['150'] -> ['140']"
188190
189191
- name: Update custom realm key (test for idempotency)
190192
community.general.keycloak_realm_key:

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
- name: install cron package
2626
package:
2727
name: '{{ cron_pkg }}'
28-
when: cron_pkg | default(false, true)
28+
when: (cron_pkg | default(false, true)) is truthy
2929
register: cron_package_installed
3030
until: cron_package_installed is success
31-
- when: faketime_pkg | default(false, true)
31+
- when: (faketime_pkg | default(false, true)) is truthy
3232
block:
3333
- name: install cron and faketime packages
3434
package:

0 commit comments

Comments
 (0)