blob: 0c3dcc0c22bcc1108b16327d05610f51eb30091f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
- hosts: localhost
gather_facts: no
environment:
ANSIBLE_LIBRARY: "{{ playbook_dir }}/library"
ANSIBLE_NOCOLOR: 1
ANSIBLE_DEPRECATION_WARNINGS: 1
vars:
# avoid header that has full path and won't work across random paths for tests
actual_output_clean: '{{ actual_output.splitlines()[1:] }}'
expected_output_clean: '{{ expected_output.splitlines()[1:] }}'
tasks:
- name: module with missing description return docs
command: ansible-doc test_docs_missing_description
register: result
ignore_errors: true
- assert:
that:
- result is failed
- |
"ERROR! Unable to retrieve documentation from 'test_docs_missing_description'. All (sub-)options and return values must have a 'description' field"
in result.stderr
- name: module with suboptions (avoid first line as it has full path)
shell: ansible-doc test_docs_suboptions| tail -n +3
register: result
ignore_errors: true
- set_fact:
actual_output: "{{ result.stdout }}"
expected_output: "{{ lookup('file', 'test_docs_suboptions.output') }}"
- assert:
that:
- result is succeeded
- actual_output_clean == expected_output_clean
- name: module with return docs
shell: ansible-doc test_docs_returns| tail -n +3
register: result
ignore_errors: true
- set_fact:
actual_output: "{{ result.stdout }}"
expected_output: "{{ lookup('file', 'test_docs_returns.output') }}"
- assert:
that:
- result is succeeded
- actual_output_clean == expected_output_clean
- name: module with broken return docs
command: ansible-doc test_docs_returns_broken
register: result
ignore_errors: true
- assert:
that:
- result is failed
- '"module test_docs_returns_broken missing documentation (or could not parse documentation)" in result.stderr'
- name: non-existent module
command: ansible-doc test_does_not_exist
register: result
- assert:
that:
- '"test_does_not_exist was not found" in result.stderr'
- name: documented module
command: ansible-doc test_docs
register: result
- assert:
that:
- '"WARNING" not in result.stderr'
- '"test_docs" in result.stdout'
- '"AUTHOR: Ansible Core Team" in result.stdout'
- name: documented module without metadata
command: ansible-doc test_docs_no_metadata
register: result
- assert:
that:
- '"WARNING" not in result.stderr'
- '"test_docs_no_metadata " in result.stdout'
- '"AUTHOR: Ansible Core Team" in result.stdout'
- name: documented module with no status in metadata
command: ansible-doc test_docs_no_status
register: result
- assert:
that:
- '"WARNING" not in result.stderr'
- '"test_docs_no_status " in result.stdout'
- '"AUTHOR: Ansible Core Team" in result.stdout'
- name: documented module with non-iterable status in metadata
command: ansible-doc test_docs_non_iterable_status
register: result
- assert:
that:
- '"WARNING" not in result.stderr'
- '"test_docs_non_iterable_status " in result.stdout'
- '"AUTHOR: Ansible Core Team" in result.stdout'
- name: documented module with removed status
command: ansible-doc test_docs_removed_status
register: result
- assert:
that:
- '"WARNING" not in result.stderr'
- '"test_docs_removed_status " in result.stdout'
- '"AUTHOR: Ansible Core Team" in result.stdout'
- name: empty module
command: ansible-doc test_empty
register: result
ignore_errors: true
- assert:
that:
- result is failed
- name: module with no documentation
command: ansible-doc test_no_docs
register: result
ignore_errors: true
- assert:
that:
- result is failed
- name: deprecated module with both removed date and version (date should get precedence)
command: ansible-doc test_docs_removed_precedence
register: result
- assert:
that:
- '"DEPRECATED" in result.stdout'
- '"Reason: Updated module released with more functionality" in result.stdout'
- '"Will be removed in a release after 2022-06-01" in result.stdout'
- '"Alternatives: new_module" in result.stdout'
- name: documented module with YAML anchors
shell: ansible-doc test_docs_yaml_anchors |tail -n +3
register: result
- set_fact:
actual_output: >-
{{ result.stdout | regex_replace('^(> [A-Z_]+ +\().+library/([a-z_]+.py)\)$', '\1library/\2)', multiline=true) }}
expected_output: "{{ lookup('file', 'test_docs_yaml_anchors.output') }}"
- assert:
that:
- actual_output == expected_output
- actual_output_clean == expected_output_clean
- name: ensure 'donothing' adjacent filter is loaded
assert:
that:
- "'x' == ('x'|donothing)"
- name: docs for deprecated plugin
command: ansible-doc deprecated_with_docs -t lookup --playbook-dir ./
register: result
- assert:
that:
- '"[WARNING]" not in result.stderr'
- '"[DEPRECATION WARNING]" in result.stderr'
- '"deprecated_with_docs " in result.stdout'
- '"AUTHOR: Ansible Core Team" in result.stdout'
- name: adjacent docs for deprecated plugin
command: ansible-doc deprecated_with_adj_docs -t lookup --playbook-dir ./
register: result
- assert:
that:
- '"[WARNING]" not in result.stderr'
- '"[DEPRECATION WARNING]" in result.stderr'
- '"deprecated_with_adj_docs " in result.stdout'
- '"AUTHOR: Ansible Core Team" in result.stdout'
|