Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/lookup_collection_version/runme.yml

raw
1 ---
2 # Copyright (c) Ansible Project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 - hosts: localhost
7 tasks:
8 - name: Test collection_version
9 assert:
10 that:
11 # Collection that does not exist
12 - query('community.general.collection_version', 'foo.bar') == [none]
13 - lookup('community.general.collection_version', 'foo.bar', result_not_found='foo') == 'foo'
14 # Collection that exists
15 - lookup('community.general.collection_version', 'community.general') is string
16 # Local collection
17 - lookup('community.general.collection_version', 'testns.testcoll') == '0.0.1'
18 # Local collection with no version
19 - lookup('community.general.collection_version', 'testns.testcoll_nv') == '*'
20 - lookup('community.general.collection_version', 'testns.testcoll_nv', result_no_version='') == ''
21 # Local collection with MANIFEST.json
22 - lookup('community.general.collection_version', 'testns.testcoll_mf') == '0.0.1'
23 # Local collection with no galaxy.yml and no MANIFEST.json
24 - lookup('community.general.collection_version', 'testns.testcoll_nothing') == '*'
25 - lookup('community.general.collection_version', 'testns.testcoll_nothing', result_no_version='0.0.0') == '0.0.0'
26 # Multiple collection names at once
27 - lookup('community.general.collection_version', 'testns.testcoll', 'testns.testcoll_nv', 'testns.testcoll_nv', 'testns.testcoll_mf', 'foo.bar')
28 == ['0.0.1', '*', '*', '0.0.1', none]
29
30 - name: Invalid FQCN
31 set_fact:
32 test: "{{ query('community.general.collection_version', 'foo.bar.baz') }}"
33 ignore_errors: true
34 register: invalid_fqcn
35
36 - name: Validate error message
37 assert:
38 that:
39 - >
40 '"foo.bar.baz" is not a FQCN' in invalid_fqcn.msg