Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/flatpak/tasks/test.yml

raw
1 ---
2 # Copyright (c) Ansible Project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 # state=present
7
8 - name: Test addition - {{ method }}
9 flatpak:
10 name: com.dummy.App1
11 remote: dummy-remote
12 state: present
13 method: "{{ method }}"
14 no_dependencies: true
15 register: addition_result
16
17 - name: Verify addition test result - {{ method }}
18 assert:
19 that:
20 - addition_result is changed
21 msg: "state=present shall add flatpak when absent"
22
23 - name: Test idempotency of addition - {{ method }}
24 flatpak:
25 name: com.dummy.App1
26 remote: dummy-remote
27 state: present
28 method: "{{ method }}"
29 no_dependencies: true
30 register: double_addition_result
31
32 - name: Verify idempotency of addition test result - {{ method }}
33 assert:
34 that:
35 - double_addition_result is not changed
36 msg: "state=present shall not do anything when flatpak is already present"
37
38 # state=absent
39
40 - name: Test removal - {{ method }}
41 flatpak:
42 name: com.dummy.App1
43 state: absent
44 method: "{{ method }}"
45 no_dependencies: true
46 register: removal_result
47
48 - name: Verify removal test result - {{ method }}
49 assert:
50 that:
51 - removal_result is changed
52 msg: "state=absent shall remove flatpak when present"
53
54 - name: Test idempotency of removal - {{ method }}
55 flatpak:
56 name: com.dummy.App1
57 state: absent
58 method: "{{ method }}"
59 no_dependencies: true
60 register: double_removal_result
61
62 - name: Verify idempotency of removal test result - {{ method }}
63 assert:
64 that:
65 - double_removal_result is not changed
66 msg: "state=absent shall not do anything when flatpak is not present"
67
68 # state=latest
69
70 - name: Test state=latest - {{ method }}
71 flatpak:
72 name: com.dummy.App1
73 remote: dummy-remote
74 state: present
75 method: "{{ method }}"
76 no_dependencies: true
77 register: latest_result
78
79 - name: Verify state=latest test result - {{ method }}
80 assert:
81 that:
82 - latest_result is changed
83 msg: "state=latest shall add flatpak when absent"
84
85 - name: Test idempotency of state=latest - {{ method }}
86 flatpak:
87 name: com.dummy.App1
88 remote: dummy-remote
89 state: present
90 method: "{{ method }}"
91 no_dependencies: true
92 register: double_latest_result
93
94 - name: Verify idempotency of state=latest test result - {{ method }}
95 assert:
96 that:
97 - double_latest_result is not changed
98 msg: "state=latest shall not do anything when flatpak is already present"
99
100 - name: Cleanup after state=present test - {{ method }}
101 flatpak:
102 name: com.dummy.App1
103 state: absent
104 method: "{{ method }}"
105 no_dependencies: true
106
107 # state=present with url as name
108
109 - name: Test addition with url - {{ method }}
110 flatpak:
111 name: http://127.0.0.1:8000/repo/com.dummy.App1.flatpakref
112 remote: dummy-remote
113 state: present
114 method: "{{ method }}"
115 no_dependencies: true
116 register: url_addition_result
117
118 - name: Verify addition test result - {{ method }}
119 assert:
120 that:
121 - url_addition_result is changed
122 msg: "state=present with url as name shall add flatpak when absent"
123
124 - name: Test idempotency of addition with url - {{ method }}
125 flatpak:
126 name: http://127.0.0.1:8000/repo/com.dummy.App1.flatpakref
127 remote: dummy-remote
128 state: present
129 method: "{{ method }}"
130 no_dependencies: true
131 register: double_url_addition_result
132
133 - name: Verify idempotency of addition with url test result - {{ method }}
134 assert:
135 that:
136 - double_url_addition_result is not changed
137 msg: "state=present with url as name shall not do anything when flatpak is already present"
138
139 # state=absent with url as name
140
141 - name: Test removal with url - {{ method }}
142 flatpak:
143 name: http://127.0.0.1:8000/repo/com.dummy.App1.flatpakref
144 state: absent
145 method: "{{ method }}"
146 no_dependencies: true
147 register: url_removal_result
148 ignore_errors: true
149
150 - name: Verify removal test result failed - {{ method }}
151 # It looks like flatpak has a bug when the hostname contains a port. If this is the case, it emits
152 # the following message, which we check for. If another error happens, we fail.
153 # Upstream issue: https://github.com/flatpak/flatpak/issues/4307
154 # (The second message happens with Ubuntu 18.04.)
155 assert:
156 that:
157 - >-
158 url_removal_result.msg in [
159 "error: Invalid branch 127.0.0.1:8000: Branch can't contain :",
160 "error: Invalid id http:: Name can't contain :",
161 ]
162 when: url_removal_result is failed
163
164 - when: url_removal_result is not failed
165 block:
166
167 - name: Verify removal test result - {{ method }}
168 assert:
169 that:
170 - url_removal_result is changed
171 msg: "state=absent with url as name shall remove flatpak when present"
172
173 - name: Test idempotency of removal with url - {{ method }}
174 flatpak:
175 name: http://127.0.0.1:8000/repo/com.dummy.App1.flatpakref
176 state: absent
177 method: "{{ method }}"
178 no_dependencies: true
179 register: double_url_removal_result
180
181 - name: Verify idempotency of removal with url test result - {{ method }}
182 assert:
183 that:
184 - double_url_removal_result is not changed
185 msg: "state=absent with url as name shall not do anything when flatpak is not present"
186
187 - name: Make sure flatpak is really gone - {{ method }}
188 flatpak:
189 name: com.dummy.App1
190 state: absent
191 method: "{{ method }}"
192 no_dependencies: true
193
194 # state=latest with url as name
195
196 - name: Test state=latest with url - {{ method }}
197 flatpak:
198 name: http://127.0.0.1:8000/repo/com.dummy.App1.flatpakref
199 remote: dummy-remote
200 state: latest
201 method: "{{ method }}"
202 no_dependencies: true
203 register: url_latest_result
204
205 - name: Verify state=latest test result - {{ method }}
206 assert:
207 that:
208 - url_latest_result is changed
209 msg: "state=present with url as name shall add flatpak when absent"
210
211 - name: Test idempotency of state=latest with url - {{ method }}
212 flatpak:
213 name: http://127.0.0.1:8000/repo/com.dummy.App1.flatpakref
214 remote: dummy-remote
215 state: latest
216 method: "{{ method }}"
217 no_dependencies: true
218 register: double_url_latest_result
219
220 - name: Verify idempotency of state=latest with url test result - {{ method }}
221 assert:
222 that:
223 - double_url_latest_result is not changed
224 msg: "state=present with url as name shall not do anything when flatpak is already present"
225
226 - name: Cleanup after state=present with url test - {{ method }}
227 flatpak:
228 name: com.dummy.App1
229 state: absent
230 method: "{{ method }}"
231 no_dependencies: true
232
233 # state=present with from_url
234
235 - name: Test addition with from_url - {{ method }}
236 flatpak:
237 name: com.dummy.App1
238 from_url: http://127.0.0.1:8000/repo/com.dummy.App1.flatpakref
239 state: present
240 method: "{{ method }}"
241 no_dependencies: true
242 register: from_url_addition_result
243
244 - name: Verify addition with from_url test result - {{ method }}
245 assert:
246 that:
247 - from_url_addition_result is changed
248 msg: "state=present with from_url shall add flatpak when absent"
249
250 - name: Test idempotency of addition with from_url - {{ method }}
251 flatpak:
252 name: com.dummy.App1
253 from_url: http://127.0.0.1:8000/repo/com.dummy.App1.flatpakref
254 state: present
255 method: "{{ method }}"
256 no_dependencies: true
257 register: double_from_url_addition_result
258
259 - name: Verify idempotency of addition with from_url test result - {{ method }}
260 assert:
261 that:
262 - double_from_url_addition_result is not changed
263 msg: "state=present with from_url shall not do anything when flatpak is already present"
264
265 - name: Cleanup after state=present with from_url test - {{ method }}
266 flatpak:
267 name: com.dummy.App1
268 state: absent
269 method: "{{ method }}"
270 no_dependencies: true
271
272 # from_url validation failures
273
274 - name: Test from_url with URL in name fails - {{ method }}
275 flatpak:
276 name: http://127.0.0.1:8000/repo/com.dummy.App1.flatpakref
277 from_url: http://127.0.0.1:8000/repo/com.dummy.App1.flatpakref
278 state: present
279 method: "{{ method }}"
280 register: from_url_url_name_result
281 ignore_errors: true
282
283 - name: Verify from_url with URL in name fails - {{ method }}
284 assert:
285 that:
286 - from_url_url_name_result is failed
287 - from_url_url_name_result is not changed
288 msg: "from_url and URL in name shall fail"
289
290 - name: Test from_url with multiple names fails - {{ method }}
291 flatpak:
292 name:
293 - com.dummy.App1
294 - com.dummy.App2
295 from_url: http://127.0.0.1:8000/repo/com.dummy.App1.flatpakref
296 state: present
297 method: "{{ method }}"
298 register: from_url_multi_name_result
299 ignore_errors: true
300
301 - name: Verify from_url with multiple names fails - {{ method }}
302 assert:
303 that:
304 - from_url_multi_name_result is failed
305 - from_url_multi_name_result is not changed
306 msg: "from_url with multiple names shall fail"
307
308 - name: Test from_url with non-http URL fails - {{ method }}
309 flatpak:
310 name: com.dummy.App1
311 from_url: file:///tmp/flatpak/repo/com.dummy.App1.flatpakref
312 state: present
313 method: "{{ method }}"
314 register: from_url_non_http_result
315 ignore_errors: true
316
317 - name: Verify from_url with non-http URL fails - {{ method }}
318 assert:
319 that:
320 - from_url_non_http_result is failed
321 - from_url_non_http_result is not changed
322 msg: "from_url with non-http URL shall fail"
323
324 # state=present with list of packages
325
326 - name: Test addition with list - {{ method }}
327 flatpak:
328 name:
329 - com.dummy.App1
330 - http://127.0.0.1:8000/repo/com.dummy.App2.flatpakref
331 remote: dummy-remote
332 state: present
333 method: "{{ method }}"
334 no_dependencies: true
335 register: addition_result
336
337 - name: Verify addition with list test result - {{ method }}
338 assert:
339 that:
340 - addition_result is changed
341 msg: "state=present shall add flatpak when absent"
342
343 - name: Test idempotency of addition with list - {{ method }}
344 flatpak:
345 name:
346 - com.dummy.App1
347 - http://127.0.0.1:8000/repo/com.dummy.App2.flatpakref
348 remote: dummy-remote
349 state: present
350 method: "{{ method }}"
351 no_dependencies: true
352 register: double_addition_result
353
354 - name: Verify idempotency of addition with list test result - {{ method }}
355 assert:
356 that:
357 - double_addition_result is not changed
358 msg: "state=present shall not do anything when flatpak is already present"
359
360 - name: Test addition with list partially installed - {{ method }}
361 flatpak:
362 name:
363 - com.dummy.App1
364 - http://127.0.0.1:8000/repo/com.dummy.App2.flatpakref
365 - com.dummy.App3
366 remote: dummy-remote
367 state: present
368 method: "{{ method }}"
369 no_dependencies: true
370 register: addition_result
371
372 - name: Verify addition with list partially installed test result - {{ method }}
373 assert:
374 that:
375 - addition_result is changed
376 msg: "state=present shall add flatpak when absent"
377
378 - name: Test idempotency of addition with list partially installed - {{ method }}
379 flatpak:
380 name:
381 - com.dummy.App1
382 - http://127.0.0.1:8000/repo/com.dummy.App2.flatpakref
383 - com.dummy.App3
384 remote: dummy-remote
385 state: present
386 method: "{{ method }}"
387 no_dependencies: true
388 register: double_addition_result
389
390 - name: Verify idempotency of addition with list partially installed test result - {{ method }}
391 assert:
392 that:
393 - double_addition_result is not changed
394 msg: "state=present shall not do anything when flatpak is already present"
395
396 # state=absent with list of packages
397
398 - name: Test removal with list - {{ method }}
399 flatpak:
400 name:
401 - com.dummy.App1
402 - com.dummy.App2
403 state: absent
404 method: "{{ method }}"
405 register: removal_result
406
407 - name: Verify removal with list test result - {{ method }}
408 assert:
409 that:
410 - removal_result is changed
411 msg: "state=absent shall remove flatpak when present"
412
413 - name: Test idempotency of removal with list - {{ method }}
414 flatpak:
415 name:
416 - com.dummy.App1
417 - com.dummy.App2
418 state: absent
419 method: "{{ method }}"
420 register: double_removal_result
421
422 - name: Verify idempotency of removal with list test result - {{ method }}
423 assert:
424 that:
425 - double_removal_result is not changed
426 msg: "state=absent shall not do anything when flatpak is not present"
427
428 - name: Test removal with list partially removed - {{ method }}
429 flatpak:
430 name:
431 - com.dummy.App1
432 - com.dummy.App2
433 - com.dummy.App3
434 state: absent
435 method: "{{ method }}"
436 register: removal_result
437
438 - name: Verify removal with list partially removed test result - {{ method }}
439 assert:
440 that:
441 - removal_result is changed
442 msg: "state=absent shall remove flatpak when present"
443
444 - name: Test idempotency of removal with list partially removed - {{ method }}
445 flatpak:
446 name:
447 - com.dummy.App1
448 - com.dummy.App2
449 - com.dummy.App3
450 state: absent
451 method: "{{ method }}"
452 register: double_removal_result
453
454 - name: Verify idempotency of removal with list partially removed test result - {{ method }}
455 assert:
456 that:
457 - double_removal_result is not changed
458 msg: "state=absent shall not do anything when flatpak is not present"
459
460 # state=latest with list of packages
461
462 - name: Test state=latest with list - {{ method }}
463 flatpak:
464 name:
465 - com.dummy.App1
466 - http://127.0.0.1:8000/repo/com.dummy.App2.flatpakref
467 remote: dummy-remote
468 state: latest
469 method: "{{ method }}"
470 no_dependencies: true
471 register: latest_result
472
473 - name: Verify state=latest with list test result - {{ method }}
474 assert:
475 that:
476 - latest_result is changed
477 msg: "state=present shall add flatpak when absent"
478
479 - name: Test idempotency of state=latest with list - {{ method }}
480 flatpak:
481 name:
482 - com.dummy.App1
483 - http://127.0.0.1:8000/repo/com.dummy.App2.flatpakref
484 remote: dummy-remote
485 state: latest
486 method: "{{ method }}"
487 no_dependencies: true
488 register: double_latest_result
489
490 - name: Verify idempotency of state=latest with list test result - {{ method }}
491 assert:
492 that:
493 - double_latest_result is not changed
494 msg: "state=present shall not do anything when flatpak is already present"
495
496 - name: Test state=latest with list partially installed - {{ method }}
497 flatpak:
498 name:
499 - com.dummy.App1
500 - http://127.0.0.1:8000/repo/com.dummy.App2.flatpakref
501 - com.dummy.App3
502 remote: dummy-remote
503 state: latest
504 method: "{{ method }}"
505 no_dependencies: true
506 register: latest_result
507
508 - name: Verify state=latest with list partially installed test result - {{ method }}
509 assert:
510 that:
511 - latest_result is changed
512 msg: "state=present shall add flatpak when absent"
513
514 - name: Test idempotency of state=latest with list partially installed - {{ method }}
515 flatpak:
516 name:
517 - com.dummy.App1
518 - http://127.0.0.1:8000/repo/com.dummy.App2.flatpakref
519 - com.dummy.App3
520 remote: dummy-remote
521 state: latest
522 method: "{{ method }}"
523 no_dependencies: true
524 register: double_latest_result
525
526 - name: Verify idempotency of state=latest with list partially installed test result - {{ method }}
527 assert:
528 that:
529 - double_latest_result is not changed
530 msg: "state=present shall not do anything when flatpak is already present"
531
532 - name: Cleanup after state=present with list test - {{ method }}
533 flatpak:
534 name:
535 - com.dummy.App1
536 - com.dummy.App2
537 - com.dummy.App3
538 state: absent
539 method: "{{ method }}"