Debian Codegraph @

ansible_collections/community/windows/tests/integration/targets/win_pester/tasks/test.yml

raw
1 ---
2 - name: Run Pester test(s) specifying a fake test file
3 win_pester:
4 path: '{{test_path}}\fakefile.ps1'
5 register: fake_file
6 failed_when: '"Cannot find file or directory: ''" + test_path + "\\fakefile.ps1'' as it does not exist" not in fake_file.msg'
7
8 - name: Run Pester test(s) specifying a fake folder
9 win_pester:
10 path: '{{test_path }}\fakedir'
11 register: fake_folder
12 failed_when: '"Cannot find file or directory: ''" + test_path + "\\fakedir'' as it does not exist" not in fake_folder.msg'
13
14 - name: Run Pester test(s) specifying a test file and a higher pester version
15 win_pester:
16 path: '{{test_path}}\test01.tests.ps1'
17 minimum_version: '6.0.0'
18 register: invalid_version
19 failed_when: '"Pester version is not greater or equal to 6.0.0" not in invalid_version.msg'
20
21 - name: Run Pester test(s) specifying a test file
22 win_pester:
23 path: '{{test_path}}\test01.tests.ps1'
24 register: file_result
25
26 - name: assert Run Pester test(s) specify a test file
27 assert:
28 that:
29 - file_result.changed
30 - not file_result.failed
31 - file_result.output.TotalCount == 1
32
33 - name: Run Pester test(s) specifying a test file and with a minimum mandatory Pester version
34 win_pester:
35 path: '{{test_path}}\test01.tests.ps1'
36 minimum_version: 3.0.0
37 register: file_result_with_version
38
39 - name: assert Run Pester test(s) specifying a test file and a minimum mandatory Pester version
40 assert:
41 that:
42 - file_result_with_version.changed
43 - not file_result_with_version.failed
44 - file_result_with_version.output.TotalCount == 1
45
46 - name: Run Pester test(s) located in a folder. Folder path end with '\'
47 win_pester:
48 path: '{{test_path}}\'
49 register: dir_with_ending_slash
50
51 - name: assert Run Pester test(s) located in a folder. Folder path end with '\'
52 assert:
53 that:
54 - dir_with_ending_slash.changed
55 - not dir_with_ending_slash.failed
56 - dir_with_ending_slash.output.TotalCount == 6
57
58 - name: Run Pester test(s) located in a folder. Folder path does not end with '\'
59 win_pester:
60 path: '{{test_path}}'
61 register: dir_without_ending_slash
62
63 - name: assert Run Pester test(s) located in a folder. Folder does not end with '\'
64 assert:
65 that:
66 - dir_without_ending_slash.changed
67 - not dir_without_ending_slash.failed
68 - dir_without_ending_slash.output.TotalCount == 6
69
70 - name: Run Pester test(s) located in a folder and with a minimum mandatory Pester version
71 win_pester:
72 path: '{{test_path}}'
73 minimum_version: 3.0.0
74 register: dir_with_version
75
76 - name: assert Run Pester test(s) located in a folder and with a minimum mandatory Pester version
77 assert:
78 that:
79 - dir_with_version.changed
80 - not dir_with_version.failed
81 - dir_with_version.output.TotalCount == 6
82
83 - name: Run Pester test(s) specifying a test file without specifying tag
84 win_pester:
85 path: '{{test_path}}\test03.tests.ps1'
86 register: test_no_tag
87
88 - name: assert Run Pester test(s) specifying a test file and all tests executed
89 assert:
90 that:
91 - test_no_tag.changed
92 - test_no_tag.output.TotalCount == 2
93
94 - name: Run Pester test(s) specifying a test file with tag
95 win_pester:
96 path: '{{test_path}}\test03.tests.ps1'
97 tags: tag1
98 register: test_with_tag
99
100 - name: Run Pester test(s) specifying a test file and only test with sepecified tag executed
101 assert:
102 that:
103 - test_with_tag.changed
104 - test_with_tag.output.TotalCount == 1
105
106 - name: Run Pester test(s) specifying a test file with parameters
107 win_pester:
108 path: '{{test_path}}\test04.tests.ps1'
109 test_parameters:
110 Process: lsass
111 Service: bits
112 register: test_with_parameter
113
114 - name: Run Pester test(s) specifying a test file with parameters
115 assert:
116 that:
117 - test_with_parameter.changed
118 - test_with_parameter.output.PassedCount == 2
119 - test_with_parameter.output.TotalCount == 2
120
121 - name: Run Pester test(s) specifying a test file by generating test result xml
122 win_pester:
123 path: '{{test_path}}\test03.tests.ps1'
124 output_file: '{{test_report_file}}'
125
126 - name: Checks if the output result file exists
127 ansible.windows.win_stat:
128 path: '{{test_report_file}}'
129 register: test_output_file
130
131 - name: Checks if the output result file exists
132 assert:
133 that:
134 - test_output_file.stat.exists