1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/tests/integration/targets/lookup_collection_version/runme.yml
Felix Fontein 5b10f8234c
Add collection_version lookup (#3633)
* Add collection_verison lookup plugin.

* Document ansible-base 2.10 and ansible-core 2.11 special case.

* Add default for result_not_found.

* Simplify not existing test.

* Move metadata loading to function.

* Update plugins/lookup/collection_version.py

Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>

* Extend tests.

* Fix tests for ansible-core < 2.12.

Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>
2021-11-01 19:01:52 +01:00

35 lines
1.8 KiB
YAML

- hosts: localhost
tasks:
- name: Test collection_version
assert:
that:
# Collection that does not exist
- query('community.general.collection_version', 'foo.bar') == [none]
- lookup('community.general.collection_version', 'foo.bar', result_not_found='foo') == 'foo'
# Collection that exists
- lookup('community.general.collection_version', 'community.general') is string
# Local collection
- lookup('community.general.collection_version', 'testns.testcoll') == '0.0.1'
# Local collection with no version
- lookup('community.general.collection_version', 'testns.testcoll_nv') == '*'
- lookup('community.general.collection_version', 'testns.testcoll_nv', result_no_version='') == ''
# Local collection with MANIFEST.json
- lookup('community.general.collection_version', 'testns.testcoll_mf') == '0.0.1'
# Local collection with no galaxy.yml and no MANIFEST.json
- lookup('community.general.collection_version', 'testns.testcoll_nothing') == '*'
- lookup('community.general.collection_version', 'testns.testcoll_nothing', result_no_version='0.0.0') == '0.0.0'
# Multiple collection names at once
- lookup('community.general.collection_version', 'testns.testcoll', 'testns.testcoll_nv', 'testns.testcoll_nv', 'testns.testcoll_mf', 'foo.bar')
== ['0.0.1', '*', '*', '0.0.1', none]
- name: Invalid FQCN
set_fact:
test: "{{ query('community.general.collection_version', 'foo.bar.baz') }}"
ignore_errors: true
register: invalid_fqcn
- name: Validate error message
assert:
that:
- >
'"foo.bar.baz" is not a FQCN' in invalid_fqcn.msg