Debian Codegraph @

ansible_collections/community/windows/plugins/modules/win_pester.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # Copyright: (c) 2018, Ansible Project
5 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7 DOCUMENTATION = r'''
8 ---
9 module: win_pester
10 short_description: Run Pester tests on Windows hosts
11 description:
12 - Run Pester tests on Windows hosts.
13 - Test files have to be available on the remote host.
14 requirements:
15 - Pester
16 options:
17 path:
18 description:
19 - Path to a pester test file or a folder where tests can be found.
20 - If the path is a folder, the module will consider all ps1 files as Pester tests.
21 type: str
22 required: true
23 tags:
24 description:
25 - Runs only tests in Describe blocks with specified Tags values.
26 - Accepts multiple comma separated tags.
27 type: list
28 elements: str
29 output_file:
30 description:
31 - Generates an output test report.
32 type: str
33 output_format:
34 description:
35 - Format of the test report to be generated.
36 - This parameter is to be used with output_file option.
37 type: str
38 default: NunitXML
39 test_parameters:
40 description:
41 - Allows to specify parameters to the test script.
42 type: dict
43 version:
44 description:
45 - Minimum version of the pester module that has to be available on the remote host.
46 type: str
47 aliases:
48 - minimum_version
49 author:
50 - Erwan Quelin (@equelin)
51 - Prasoon Karunan V (@prasoonkarunan)
52 '''
53
54 EXAMPLES = r'''
55 - name: Get facts
56 ansible.windows.setup:
57
58 - name: Add Pester module
59 action:
60 module_name: "{{ 'community.windows.win_psmodule' if ansible_powershell_version >= 5 else 'chocolatey.chocolatey.win_chocolatey' }}"
61 name: Pester
62 state: present
63
64 - name: Run the pester test provided in the path parameter.
65 community.windows.win_pester:
66 path: C:\Pester
67
68 - name: Run the pester tests only for the tags specified.
69 community.windows.win_pester:
70 path: C:\Pester\TestScript.tests
71 tags: CI,UnitTests
72
73 # Run pesters tests files that are present in the specified folder
74 # ensure that the pester module version available is greater or equal to the version parameter.
75 - name: Run the pester test present in a folder and check the Pester module version.
76 community.windows.win_pester:
77 path: C:\Pester\test01.test.ps1
78 version: 4.1.0
79
80 - name: Run the pester test present in a folder with given script parameters.
81 community.windows.win_pester:
82 path: C:\Pester\test04.test.ps1
83 test_parameters:
84 Process: lsass
85 Service: bits
86
87 - name: Run the pester test present in a folder and generate NunitXML test result..
88 community.windows.win_pester:
89 path: C:\Pester\test04.test.ps1
90 output_file: c:\Pester\resullt\testresult.xml
91 '''
92
93 RETURN = r'''
94 pester_version:
95 description: Version of the pester module found on the remote host.
96 returned: always
97 type: str
98 sample: 4.3.1
99 output:
100 description: Results of the Pester tests.
101 returned: success
102 type: list
103 sample: false
104 '''