diff options
author | Felix Fontein <felix@fontein.de> | 2023-09-11 15:31:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-11 15:31:52 +0200 |
commit | b1b029c6b57239e294f50fd0985e55bf492b068b (patch) | |
tree | 63be41d8916cd97b070c46c101a0144b10d1d3fd /test/integration | |
parent | Only mark a role as complete once a task in it executes for the target host (... (diff) | |
download | ansible-b1b029c6b57239e294f50fd0985e55bf492b068b.tar.xz ansible-b1b029c6b57239e294f50fd0985e55bf492b068b.zip |
ansible-doc: allow to filter by more than one collection (#81450)
Make collection filters more flexible for listing collections.
Co-authored-by: Maxwell G <maxwell@gtmx.me>
Diffstat (limited to 'test/integration')
5 files changed, 79 insertions, 0 deletions
diff --git a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol3/galaxy.yml b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol3/galaxy.yml new file mode 100644 index 0000000000..bd6c15a449 --- /dev/null +++ b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol3/galaxy.yml @@ -0,0 +1,6 @@ +namespace: testns +name: testcol3 +version: 0.1.0 +readme: README.md +authors: + - me diff --git a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol3/plugins/modules/test1.py b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol3/plugins/modules/test1.py new file mode 100644 index 0000000000..02dfb89d56 --- /dev/null +++ b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol3/plugins/modules/test1.py @@ -0,0 +1,27 @@ +#!/usr/bin/python +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +DOCUMENTATION = """ +module: test1 +short_description: Foo module in testcol3 +description: + - This is a foo module. +author: + - me +""" + +from ansible.module_utils.basic import AnsibleModule + + +def main(): + module = AnsibleModule( + argument_spec=dict(), + ) + + module.exit_json() + + +if __name__ == '__main__': + main() diff --git a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol4/galaxy.yml b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol4/galaxy.yml new file mode 100644 index 0000000000..7894d393ca --- /dev/null +++ b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol4/galaxy.yml @@ -0,0 +1,6 @@ +namespace: testns +name: testcol4 +version: 1.0.0 +readme: README.md +authors: + - me diff --git a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol4/plugins/modules/test2.py b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol4/plugins/modules/test2.py new file mode 100644 index 0000000000..ddb0c114fa --- /dev/null +++ b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol4/plugins/modules/test2.py @@ -0,0 +1,27 @@ +#!/usr/bin/python +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +DOCUMENTATION = """ +module: test2 +short_description: Foo module in testcol4 +description: + - This is a foo module. +author: + - me +""" + +from ansible.module_utils.basic import AnsibleModule + + +def main(): + module = AnsibleModule( + argument_spec=dict(), + ) + + module.exit_json() + + +if __name__ == '__main__': + main() diff --git a/test/integration/targets/ansible-doc/runme.sh b/test/integration/targets/ansible-doc/runme.sh index 14f746c60b..b525766cfa 100755 --- a/test/integration/targets/ansible-doc/runme.sh +++ b/test/integration/targets/ansible-doc/runme.sh @@ -60,6 +60,14 @@ ansible-doc --list testns.testcol --playbook-dir ./ 2>&1 | grep $GREP_OPTS -v "I echo "ensure we dont break on invalid collection name for list" ansible-doc --list testns.testcol.fakemodule --playbook-dir ./ 2>&1 | grep $GREP_OPTS "Invalid collection name" +echo "filter list with more than one collection (1/2)" +output=$(ansible-doc --list testns.testcol3 testns.testcol4 --playbook-dir ./ 2>&1 | wc -l) +test "$output" -eq 2 + +echo "filter list with more than one collection (2/2)" +output=$(ansible-doc --list testns.testcol testns.testcol4 --playbook-dir ./ 2>&1 | wc -l) +test "$output" -eq 5 + echo "testing ansible-doc output for various plugin types" for ptype in cache inventory lookup vars filter module do @@ -114,6 +122,11 @@ echo "testing multiple role entrypoints" output=$(ansible-doc -t role -l --playbook-dir . testns.testcol | wc -l) test "$output" -eq 2 +echo "test listing roles with multiple collection filters" +# Two collection roles are defined, but only 1 has a role arg spec with 2 entry points +output=$(ansible-doc -t role -l --playbook-dir . testns.testcol2 testns.testcol | wc -l) +test "$output" -eq 2 + echo "testing standalone roles" # Include normal roles (no collection filter) output=$(ansible-doc -t role -l --playbook-dir . | wc -l) |