You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: hacking/update_examples_and_tests.sh
+16-11Lines changed: 16 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -4,22 +4,27 @@ for module in ../plugins/modules/*.py; do
4
4
module_name="$(basename "${module}" .py)"
5
5
6
6
# create examples
7
-
echo"---"| tee "../examples/${module_name}.yml"
7
+
echo"---"| tee "../examples/${module_name}.yml"1> /dev/null
8
8
# https://stackoverflow.com/a/22221307
9
-
sed -n '/EXAMPLES/,/"""/{/EXAMPLES/b;/"""/b;p}'"${module}"| tee -a "../examples/${module_name}.yml"
9
+
sed -n '/EXAMPLES/,/"""/{/EXAMPLES/b;/"""/b;p}'"${module}"| tee -a "../examples/${module_name}.yml"1> /dev/null
10
10
11
11
# create tests
12
-
echo"---"| tee "../tests/integration/targets/icinga/roles/icinga/tasks/${module_name}.yml"
13
-
sed -n '/EXAMPLES/,/"""/{/EXAMPLES/b;/"""/b;p}'"${module}"| tee -a "../tests/integration/targets/icinga/roles/icinga/tasks/${module_name}.yml"
12
+
echo"---"| tee "../tests/integration/targets/icinga/roles/icinga/tasks/${module_name}.yml"1> /dev/null
13
+
sed -n '/EXAMPLES/,/"""/{/EXAMPLES/b;/"""/b;p}'"${module}"| tee -a "../tests/integration/targets/icinga/roles/icinga/tasks/${module_name}.yml"1> /dev/null
14
14
15
-
# create create working tests deleting the hosts
16
-
echo"---"| tee "../tests/integration/targets/icinga/roles/icinga/tasks/absent_${module_name}.yml"
17
-
sed -n '/EXAMPLES/,/"""/{/EXAMPLES/b;/"""/b;p}'"${module}"| tee -a "../tests/integration/targets/icinga/roles/icinga/tasks/absent_${module_name}.yml"
15
+
# create working tests deleting the hosts
16
+
echo"---"| tee "../tests/integration/targets/icinga/roles/icinga/tasks/absent_${module_name}.yml"1> /dev/null
17
+
sed -n '/EXAMPLES/,/"""/{/EXAMPLES/b;/"""/b;p}'"${module}"| tee -a "../tests/integration/targets/icinga/roles/icinga/tasks/absent_${module_name}.yml"1> /dev/null
18
18
sed -i 's/state: present/state: absent/g'"../tests/integration/targets/icinga/roles/icinga/tasks/absent_${module_name}.yml"
19
19
20
+
# delete imports and command from the tests, because they aren't necessary to delete an object
21
+
# regression test for https://github.com/T-Systems-MMS/ansible-collection-icinga-director/issues/44
22
+
sed -i '/imports:/,+1d'"../tests/integration/targets/icinga/roles/icinga/tasks/absent_${module_name}.yml"
23
+
sed -i '/^\s*command:/d'"../tests/integration/targets/icinga/roles/icinga/tasks/absent_${module_name}.yml"
24
+
20
25
# create failing tests with wrong password
21
-
echo"---"| tee "../tests/integration/targets/icinga/roles/icinga/tasks/wrong_pass_${module_name}.yml"
22
-
sed -n '/EXAMPLES/,/"""/{/EXAMPLES/b;/"""/b;p}'"${module}"| tee -a "../tests/integration/targets/icinga/roles/icinga/tasks/wrong_pass_${module_name}.yml"
26
+
echo"---"| tee "../tests/integration/targets/icinga/roles/icinga/tasks/wrong_pass_${module_name}.yml"1> /dev/null
27
+
sed -n '/EXAMPLES/,/"""/{/EXAMPLES/b;/"""/b;p}'"${module}"| tee -a "../tests/integration/targets/icinga/roles/icinga/tasks/wrong_pass_${module_name}.yml"1> /dev/null
23
28
# replace password variable with wrong password
24
29
sed -i 's/{{ icinga_pass }}/iamwrong/g'"../tests/integration/targets/icinga/roles/icinga/tasks/wrong_pass_${module_name}.yml"
25
30
@@ -37,8 +42,8 @@ for module in ../plugins/modules/*.py; do
37
42
38
43
# create failing tests with wrong host
39
44
# add test
40
-
echo"---"| tee "../tests/integration/targets/icinga/roles/icinga/tasks/wrong_host_${module_name}.yml"
41
-
sed -n '/EXAMPLES/,/"""/{/EXAMPLES/b;/"""/b;p}'"${module}"| tee -a "../tests/integration/targets/icinga/roles/icinga/tasks/wrong_host_${module_name}.yml"
45
+
echo"---"| tee "../tests/integration/targets/icinga/roles/icinga/tasks/wrong_host_${module_name}.yml"1> /dev/null
46
+
sed -n '/EXAMPLES/,/"""/{/EXAMPLES/b;/"""/b;p}'"${module}"| tee -a "../tests/integration/targets/icinga/roles/icinga/tasks/wrong_host_${module_name}.yml"1> /dev/null
42
47
# replace url varuable with nonexisting url
43
48
sed -i 's/{{ icinga_url }}/http:\/\/nonexistant/g'"../tests/integration/targets/icinga/roles/icinga/tasks/wrong_host_${module_name}.yml"
0 commit comments