Skip to content

Commit a1e968d

Browse files
author
Shashank Venkat
committed
fixed sample_test and the docs
1 parent a48d176 commit a1e968d

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

docs/installing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ $ ansible-creator add plugin <plugin-type> <plugin-name> <collection-path>
381381
| filter | Add a filter plugin to an existing Ansible Collection. |
382382
| lookup | Add a lookup plugin to an existing Ansible Collection. |
383383
| module | Add a generic module to an existing Ansible Collection. |
384+
| test | Add a test plugin to an existing Ansible Collection |
384385

385386
#### Example of adding a plugin
386387

src/ansible_creator/resources/collection_project/plugins/test/sample_test.py.j2

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,23 @@ DOCUMENTATION = """
2525
version_added: "1.0.0"
2626
short_description: {{ description }}
2727
description:
28-
- This is a demo test plugin designed to return Hello message.
28+
- This is a demo test plugin designed to return a bool.
2929
options:
3030
name:
31-
description: Value specified here is appended to the Hello message.
32-
type: str
31+
type: bool
3332
"""
3433

3534
EXAMPLES = """
3635
# {{ test_name }} test example
3736
{% raw %}
38-
- name: Display a hello message
37+
- name: Display a bool
3938
ansible.builtin.debug:
4039
msg: "{{ 50 {%- endraw %} | {{ test_name }} }}"
4140
"""
4241

4342

44-
def _hello_world(val: int) -> bool:
45-
"""Returns Hello message.
43+
def _sample_test(val: int) -> bool:
44+
"""Returns a bool.
4645

4746
Args:
4847
val: The value to test.
@@ -62,4 +61,4 @@ class TestModule:
6261
Returns:
6362
dict: The test plugin functions.
6463
"""
65-
return {"{{ test_name }}": _hello_world}
64+
return {"{{ test_name }}": _sample_test}

tests/fixtures/collection/testorg/testcol/plugins/test/sample_test.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,23 @@
2020
version_added: "1.0.0"
2121
short_description: A custom test plugin for Ansible.
2222
description:
23-
- This is a demo test plugin designed to return Hello message.
23+
- This is a demo test plugin designed to return a bool.
2424
options:
2525
name:
26-
description: Value specified here is appended to the Hello message.
27-
type: str
26+
type: bool
2827
"""
2928

3029
EXAMPLES = """
3130
# sample_test test example
3231
33-
- name: Display a hello message
32+
- name: Display a bool
3433
ansible.builtin.debug:
3534
msg: "{{ 50 | sample_test }}"
3635
"""
3736

3837

39-
def _hello_world(val: int) -> bool:
40-
"""Returns Hello message.
38+
def _sample_test(val: int) -> bool:
39+
"""Returns a bool.
4140
4241
Args:
4342
val: The value to test.
@@ -57,4 +56,4 @@ def tests(self) -> dict[str, Callable[[int], bool]]:
5756
Returns:
5857
dict: The test plugin functions.
5958
"""
60-
return {"sample_test": _hello_world}
59+
return {"sample_test": _sample_test}

0 commit comments

Comments
 (0)