Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/cmd_runner/vars/main.yml

raw
1 # Copyright (c) 2022, Alexei Znamensky
2 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
3 # SPDX-License-Identifier: GPL-3.0-or-later
4
5 cmd_echo_tests:
6 - name: set aa and bb value
7 arg_formats:
8 aa:
9 func: as_opt_eq_val
10 args: [--answer]
11 bb:
12 func: as_bool
13 args: [--bb-here]
14 arg_order: 'aa bb'
15 arg_values:
16 bb: true
17 aa: 11
18 assertions:
19 - test_result.rc == 0
20 - test_result.out == "-- --answer=11 --bb-here\n"
21 - test_result.err == ""
22
23 - name: default aa value
24 arg_formats:
25 aa:
26 func: as_opt_eq_val
27 args: [--answer]
28 bb:
29 func: as_bool
30 args: [--bb-here]
31 arg_order: ['aa', 'bb']
32 arg_values:
33 aa: 43
34 bb: true
35 assertions:
36 - test_result.rc == 0
37 - test_result.out == "-- --answer=43 --bb-here\n"
38 - test_result.err == ""
39
40 - name: missing bb format
41 arg_order: ['aa', 'bb']
42 arg_formats:
43 aa:
44 func: as_opt_eq_val
45 args: [--answer]
46 arg_values:
47 bb: true
48 aa: 1984
49 expect_error: true
50 assertions:
51 - test_result is failed
52 - test_result.rc == 1
53 - '"out" not in test_result'
54 - '"err" not in test_result'
55 - >-
56 "MissingArgumentFormat: Cannot find format for parameter bb"
57 in test_result.module_stderr
58
59 - name: missing bb value
60 arg_formats:
61 aa:
62 func: as_opt_eq_val
63 args: [--answer]
64 bb:
65 func: as_bool
66 args: [--bb-here]
67 arg_order: 'aa bb'
68 aa: 1984
69 expect_error: true
70 assertions:
71 - test_result is failed
72 - test_result.rc == 1
73 - '"out" not in test_result'
74 - '"err" not in test_result'
75 - >-
76 "MissingArgumentValue: Cannot find value for parameter bb"
77 in test_result.module_stderr
78
79 - name: set aa and bb value with check_mode on
80 arg_formats:
81 aa:
82 func: as_opt_eq_val
83 args: [--answer]
84 bb:
85 func: as_bool
86 args: [--bb-here]
87 arg_order: 'aa bb'
88 arg_values:
89 bb: true
90 aa: 11
91 check_mode: true
92 assertions:
93 - test_result.rc == 0
94 - test_result.out == "-- --answer=11 --bb-here\n"
95 - test_result.err == ""
96
97 - name: set aa and bb value with check_mode and check_mode_skip on
98 arg_formats:
99 aa:
100 func: as_opt_eq_val
101 args: [--answer]
102 bb:
103 func: as_bool
104 args: [--bb-here]
105 arg_order: 'aa bb'
106 arg_values:
107 bb: true
108 check_mode_skip: true
109 aa: 11
110 check_mode: true
111 expect_error: true # because if result contains rc != 0, ansible assumes error
112 assertions:
113 - test_result.rc | default(None) == None
114 - test_result.out | default(None) == None
115 - test_result.err | default(None) == None
116
117 - name: set aa and tt value
118 arg_formats:
119 aa:
120 func: as_opt_eq_val
121 args: [--answer]
122 tt:
123 func: as_opt_val
124 args: [--tt-arg]
125 arg_order: 'aa tt'
126 arg_values:
127 tt: potatoes
128 aa: 11
129 assertions:
130 - test_result.rc == 0
131 - test_result.out == "-- --answer=11 --tt-arg potatoes\n"
132 - test_result.err == ""
133
134 - name: use cmd echo
135 cmd: echo
136 arg_formats:
137 aa:
138 func: as_opt_eq_val
139 args: [--answer]
140 tt:
141 func: as_opt_val
142 args: [--tt-arg]
143 arg_order: 'aa tt'
144 arg_values:
145 tt: potatoes
146 aa: 11
147 assertions:
148 - test_result.rc == 0
149 - test_result.out == "-- --answer=11 --tt-arg potatoes\n"
150 - test_result.err == ""
151
152 - name: use cmd /bin/echo
153 cmd: /bin/echo
154 arg_formats:
155 aa:
156 func: as_opt_eq_val
157 args: [--answer]
158 tt:
159 func: as_opt_val
160 args: [--tt-arg]
161 arg_order: 'aa tt'
162 arg_values:
163 tt: potatoes
164 aa: 11
165 assertions:
166 - test_result.rc == 0
167 - test_result.out == "-- --answer=11 --tt-arg potatoes\n"
168 - test_result.err == ""
169
170 # this will not be in the regular set of paths get_bin_path() searches
171 - name: use cmd {{ remote_tmp_dir }}/echo
172 condition: >
173 {{ ansible_facts.distribution != "MacOSX" }}
174 copy_to: "{{ remote_tmp_dir }}"
175 cmd: "{{ remote_tmp_dir }}/echo"
176 arg_formats:
177 aa:
178 func: as_opt_eq_val
179 args: [--answer]
180 tt:
181 func: as_opt_val
182 args: [--tt-arg]
183 arg_order: 'aa tt'
184 arg_values:
185 tt: potatoes
186 aa: 11
187 assertions:
188 - test_result.rc == 0
189 - test_result.out == "-- --answer=11 --tt-arg potatoes\n"
190 - test_result.err == ""
191
192 - name: use cmd echo with path_prefix {{ remote_tmp_dir }}
193 cmd: echo
194 condition: >
195 {{ ansible_facts.distribution != "MacOSX" }}
196 copy_to: "{{ remote_tmp_dir }}"
197 path_prefix: "{{ remote_tmp_dir }}"
198 arg_formats:
199 aa:
200 func: as_opt_eq_val
201 args: [--answer]
202 tt:
203 func: as_opt_val
204 args: [--tt-arg]
205 arg_order: 'aa tt'
206 arg_values:
207 tt: potatoes
208 aa: 11
209 assertions:
210 - test_result.rc == 0
211 - test_result.out == "-- --answer=11 --tt-arg potatoes\n"
212 - test_result.err == ""
213
214 - name: use cmd never-existed
215 cmd: never-existed
216 arg_formats:
217 aa:
218 func: as_opt_eq_val
219 args: [--answer]
220 tt:
221 func: as_opt_val
222 args: [--tt-arg]
223 arg_order: 'aa tt'
224 arg_values:
225 tt: potatoes
226 aa: 11
227 expect_error: true
228 assertions:
229 - >
230 "Failed to find required executable" in test_result.msg
231
232 - name: use cmd /usr/bin/never-existed
233 cmd: /usr/bin/never-existed
234 arg_formats:
235 aa:
236 func: as_opt_eq_val
237 args: [--answer]
238 tt:
239 func: as_opt_val
240 args: [--tt-arg]
241 arg_order: 'aa tt'
242 arg_values:
243 tt: potatoes
244 aa: 11
245 expect_error: true
246 assertions:
247 - >
248 "No such file or directory" in test_result.msg
249 or
250 "Error executing command." == test_result.msg