Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/snap_alias/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 - name: Ensure snap 'hello-world' is not installed
7 community.general.snap:
8 name: hello-world
9 state: absent
10
11 - name: Ensure snap 'hello-world' is installed fresh
12 community.general.snap:
13 name: hello-world
14
15 ################################################################################
16
17 - name: Create snap alias (check mode)
18 community.general.snap_alias:
19 name: hello-world
20 alias: hw
21 check_mode: true
22 register: alias_single_0
23
24 - name: Create snap alias
25 community.general.snap_alias:
26 name: hello-world
27 alias: hw
28 register: alias_single_1
29
30 - name: Create snap alias (check mode idempotent)
31 community.general.snap_alias:
32 name: hello-world
33 alias: hw
34 check_mode: true
35 register: alias_single_2
36
37 - name: Create snap alias (idempotent)
38 community.general.snap_alias:
39 name: hello-world
40 alias: hw
41 register: alias_single_3
42
43 - name: assert single alias
44 assert:
45 that:
46 - alias_single_0 is changed
47 - alias_single_1 is changed
48 - alias_single_2 is not changed
49 - alias_single_3 is not changed
50 - 'alias_single_1.snap_aliases["hello-world"] == ["hw"]'
51 - 'alias_single_3.snap_aliases["hello-world"] == ["hw"]'
52
53 - name: Create multiple aliases (check mode)
54 community.general.snap_alias:
55 name: hello-world
56 aliases: [hw, hw2, hw3]
57 check_mode: true
58 register: alias_multi_0
59
60 - name: Create multiple aliases
61 community.general.snap_alias:
62 name: hello-world
63 aliases: [hw, hw2, hw3]
64 register: alias_multi_1
65
66 - name: Create multiple aliases (check mode idempotent)
67 community.general.snap_alias:
68 name: hello-world
69 aliases: [hw, hw2, hw3]
70 check_mode: true
71 register: alias_multi_2
72
73 - name: Create multiple aliases (idempotent)
74 community.general.snap_alias:
75 name: hello-world
76 aliases: [hw, hw2, hw3]
77 register: alias_multi_3
78
79 - name: assert multi alias
80 assert:
81 that:
82 - alias_multi_0 is changed
83 - alias_multi_1 is changed
84 - alias_multi_2 is not changed
85 - alias_multi_3 is not changed
86 - 'alias_multi_1.snap_aliases["hello-world"] == ["hw", "hw2", "hw3"]'
87 - 'alias_multi_3.snap_aliases["hello-world"] == ["hw", "hw2", "hw3"]'
88
89 - name: Remove one specific alias (check mode)
90 community.general.snap_alias:
91 alias: hw
92 state: absent
93 check_mode: true
94 register: alias_remove_0
95
96 - name: Remove one specific alias
97 community.general.snap_alias:
98 alias: hw
99 state: absent
100 register: alias_remove_1
101
102 - name: Remove one specific alias (check mode idempotent)
103 community.general.snap_alias:
104 alias: hw
105 state: absent
106 check_mode: true
107 register: alias_remove_2
108
109 - name: Remove one specific alias (idempotent)
110 community.general.snap_alias:
111 alias: hw
112 state: absent
113 register: alias_remove_3
114
115 - name: assert remove alias
116 assert:
117 that:
118 - alias_remove_0 is changed
119 - alias_remove_1 is changed
120 - alias_remove_2 is not changed
121 - alias_remove_3 is not changed
122 - 'alias_remove_1.snap_aliases["hello-world"] == ["hw2", "hw3"]'
123 - 'alias_remove_3.snap_aliases["hello-world"] == ["hw2", "hw3"]'
124
125 - name: Remove all aliases for snap (check mode)
126 community.general.snap_alias:
127 name: hello-world
128 state: absent
129 check_mode: true
130 register: alias_remove_all_0
131
132 - name: Remove all aliases for snap
133 community.general.snap_alias:
134 name: hello-world
135 state: absent
136 register: alias_remove_all_1
137
138 - name: Remove all aliases for snap (check mode idempotent)
139 community.general.snap_alias:
140 name: hello-world
141 state: absent
142 check_mode: true
143 register: alias_remove_all_2
144
145 - name: Remove all aliases for snap (idempotent)
146 community.general.snap_alias:
147 name: hello-world
148 state: absent
149 register: alias_remove_all_3
150
151 - name: assert remove_all alias
152 assert:
153 that:
154 - alias_remove_all_0 is changed
155 - alias_remove_all_1 is changed
156 - alias_remove_all_2 is not changed
157 - alias_remove_all_3 is not changed
158 - 'alias_remove_all_1.snap_aliases["hello-world"] == []'
159 - 'alias_remove_all_3.snap_aliases["hello-world"] == []'