Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/kdeconfig/tasks/main.yml

raw
1 ---
2 ####################################################################
3 # WARNING: These are designed specifically for Ansible tests #
4 # and should not be used as examples of how to write Ansible roles #
5 ####################################################################
6
7 # Copyright (c) 2023, Salvatore Mesoraca <[email protected]>
8 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
9 # SPDX-License-Identifier: GPL-3.0-or-later
10
11 - name: Set paths
12 set_fact:
13 output_file: "{{ remote_tmp_dir }}/kdeconf"
14 kwriteconf_fake: "{{ remote_tmp_dir }}/kwriteconf"
15
16 - name: Install fake kwriteconf
17 copy:
18 dest: "{{ kwriteconf_fake }}"
19 src: kwriteconf_fake
20 mode: "0755"
21
22 - name: Simple test
23 kdeconfig:
24 path: "{{ output_file }}"
25 values:
26 - group: test
27 key: test1
28 value: test2
29 kwriteconfig_path: "{{ kwriteconf_fake }}"
30 register: result_simple
31 ignore_errors: true
32
33 - name: Simple test - checks
34 assert:
35 that:
36 - result_simple is changed
37 - result_simple is not failed
38
39 - name: Simple test - idempotence
40 kdeconfig:
41 path: "{{ output_file }}"
42 values:
43 - group: test
44 key: test1
45 value: test2
46 kwriteconfig_path: "{{ kwriteconf_fake }}"
47 register: result_simple_idem
48 ignore_errors: true
49
50 - name: Simple test - idempotence - checks
51 assert:
52 that:
53 - result_simple_idem is not changed
54 - result_simple_idem is not failed
55
56 - name: Reset
57 file:
58 path: "{{ output_file }}"
59 state: absent
60
61 - name: Group and groups are mutually exclusive
62 kdeconfig:
63 path: "{{ output_file }}"
64 values:
65 - group: test
66 groups: [test2]
67 key: test1
68 value: test2
69 kwriteconfig_path: "{{ kwriteconf_fake }}"
70 register: result_group_mutex
71 ignore_errors: true
72
73 - name: Group and groups are mutually exclusive - checks
74 assert:
75 that:
76 - result_group_mutex is not changed
77 - result_group_mutex is failed
78 - "result_group_mutex.msg == 'parameters are mutually exclusive: group|groups found in values'"
79
80 - name: value and bool_value are mutually exclusive
81 kdeconfig:
82 path: "{{ output_file }}"
83 values:
84 - group: test
85 key: test1
86 value: test2
87 bool_value: true
88 kwriteconfig_path: "{{ kwriteconf_fake }}"
89 register: result_val_mutex
90 ignore_errors: true
91
92 - name: value and bool_value are mutually exclusive - checks
93 assert:
94 that:
95 - result_val_mutex is not changed
96 - result_val_mutex is failed
97 - "result_val_mutex.msg == 'parameters are mutually exclusive: value|bool_value found in values'"
98
99 - name: bool_value must be bool
100 kdeconfig:
101 path: "{{ output_file }}"
102 values:
103 - group: test
104 key: test1
105 bool_value: thisisastring
106 kwriteconfig_path: "{{ kwriteconf_fake }}"
107 register: result_val_bool
108 ignore_errors: true
109
110 - name: bool_value must be bool - checks
111 assert:
112 that:
113 - result_val_bool is not changed
114 - result_val_bool is failed
115 - "'is not a valid boolean' in result_val_bool.msg"
116
117 - name: Multiple groups test
118 kdeconfig:
119 path: "{{ output_file }}"
120 values:
121 - groups:
122 - test
123 - test1
124 - test2
125 key: test3
126 value: test4
127 kwriteconfig_path: "{{ kwriteconf_fake }}"
128 register: result_groups
129 ignore_errors: true
130
131 - name: Multiple groups test - checks
132 assert:
133 that:
134 - result_groups is changed
135 - result_groups is not failed
136
137 - name: Multiple groups test - idempotence
138 kdeconfig:
139 path: "{{ output_file }}"
140 values:
141 - groups:
142 - test
143 - test1
144 - test2
145 key: test3
146 value: test4
147 kwriteconfig_path: "{{ kwriteconf_fake }}"
148 register: result_groups_idem
149 ignore_errors: true
150
151 - name: Multiple groups test - idempotence - checks
152 assert:
153 that:
154 - result_groups_idem is not changed
155 - result_groups_idem is not failed
156
157 - name: Reset
158 file:
159 path: "{{ output_file }}"
160 state: absent
161
162 - name: Bool test
163 kdeconfig:
164 path: "{{ output_file }}"
165 values:
166 - group: test
167 key: test1
168 bool_value: true
169 kwriteconfig_path: "{{ kwriteconf_fake }}"
170 register: result_bool
171 ignore_errors: true
172
173 - name: Simple test - checks
174 assert:
175 that:
176 - result_bool is changed
177 - result_bool is not failed
178
179 - name: Bool test - idempotence
180 kdeconfig:
181 path: "{{ output_file }}"
182 values:
183 - group: test
184 key: test1
185 bool_value: true
186 kwriteconfig_path: "{{ kwriteconf_fake }}"
187 register: result_bool_idem
188 ignore_errors: true
189
190 - name: Bool test - idempotence - checks
191 assert:
192 that:
193 - result_bool_idem is not changed
194 - result_bool_idem is not failed
195
196 - name: Reset
197 file:
198 path: "{{ output_file }}"
199 state: absent
200
201 - name: check_mode test
202 kdeconfig:
203 path: "{{ output_file }}"
204 values:
205 - group: test
206 key: test1
207 value: test2
208 - groups: [testx, testy]
209 key: testz
210 bool_value: true
211 kwriteconfig_path: "{{ kwriteconf_fake }}"
212 register: result_checkmode
213 ignore_errors: true
214 check_mode: true
215 diff: true
216
217 - name: check_mode test file contents
218 slurp:
219 src: "{{ output_file }}"
220 register: check_mode_contents
221 ignore_errors: true
222
223 - name: check_mode test - checks
224 assert:
225 that:
226 - result_checkmode is changed
227 - result_checkmode is not failed
228 - check_mode_contents is failed
229
230 - name: check_mode test - apply
231 kdeconfig:
232 path: "{{ output_file }}"
233 values:
234 - group: test
235 key: test1
236 value: test2
237 - groups: [testx, testy]
238 key: testz
239 bool_value: true
240 kwriteconfig_path: "{{ kwriteconf_fake }}"
241 register: result_checkmode_apply
242 ignore_errors: true
243 check_mode: false
244 diff: true
245
246 - name: check_mode test - apply - checks
247 assert:
248 that:
249 - result_checkmode_apply is changed
250 - result_checkmode_apply is not failed
251 - "result_checkmode_apply['diff']['after'] == result_checkmode['diff']['after']"
252 - "result_checkmode_apply['diff']['before'] == result_checkmode['diff']['before']"
253
254 - name: check_mode test - idempotence
255 kdeconfig:
256 path: "{{ output_file }}"
257 values:
258 - group: test
259 key: test1
260 value: test2
261 - groups: [testx, testy]
262 key: testz
263 bool_value: true
264 kwriteconfig_path: "{{ kwriteconf_fake }}"
265 register: result_checkmode2
266 ignore_errors: true
267 check_mode: true
268
269 - name: check_mode test - idempotence - checks
270 assert:
271 that:
272 - result_checkmode2 is not changed
273 - result_checkmode2 is not failed
274
275 - name: Reset
276 file:
277 path: "{{ output_file }}"
278 state: absent
279
280 - name: Unicode test
281 kdeconfig:
282 path: "{{ output_file }}"
283 values:
284 - group: tesòt
285 key: testè1
286 value: testù2
287 kwriteconfig_path: "{{ kwriteconf_fake }}"
288 register: result_unicode
289 ignore_errors: true
290
291 - name: Unicode test - checks
292 assert:
293 that:
294 - result_unicode is changed
295 - result_unicode is not failed
296
297 - name: Reset
298 file:
299 path: "{{ output_file }}"
300 state: absent
301
302 - name: Missing groups
303 kdeconfig:
304 path: "{{ output_file }}"
305 values:
306 - key: test1
307 value: test2
308 kwriteconfig_path: "{{ kwriteconf_fake }}"
309 register: result_mgroup
310 ignore_errors: true
311
312 - name: Missing groups - checks
313 assert:
314 that:
315 - result_mgroup is not changed
316 - result_mgroup is failed
317 - "result_mgroup.msg == 'one of the following is required: group, groups found in values'"
318
319 - name: Missing key
320 kdeconfig:
321 path: "{{ output_file }}"
322 values:
323 - group: test1
324 value: test2
325 kwriteconfig_path: "{{ kwriteconf_fake }}"
326 register: result_mkey
327 ignore_errors: true
328
329 - name: Missing key - checks
330 assert:
331 that:
332 - result_mkey is not changed
333 - result_mkey is failed
334 - "result_mkey.msg == 'missing required arguments: key found in values'"
335
336 - name: Missing value
337 kdeconfig:
338 path: "{{ output_file }}"
339 values:
340 - group: test1
341 key: test2
342 kwriteconfig_path: "{{ kwriteconf_fake }}"
343 register: result_mvalue
344 ignore_errors: true
345
346 - name: Missing value - checks
347 assert:
348 that:
349 - result_mvalue is not changed
350 - result_mvalue is failed
351 - "result_mvalue.msg == 'one of the following is required: value, bool_value found in values'"
352
353 - name: Empty key
354 kdeconfig:
355 path: "{{ output_file }}"
356 values:
357 - group: test1
358 key: ''
359 value: test2
360 kwriteconfig_path: "{{ kwriteconf_fake }}"
361 register: result_ekey
362 ignore_errors: true
363
364 - name: Empty key - checks
365 assert:
366 that:
367 - result_ekey is not changed
368 - result_ekey is failed
369 - "result_ekey.msg == \"'key' cannot be empty\""