Debian Codegraph @

test/integration/targets/ansible-galaxy-collection-scm/tasks/requirements.yml

raw
1 - name: make a requirements directory
2 file:
3 state: directory
4 path: '{{ galaxy_dir }}/requirements'
5
6 - name: populate requirement templates
7 template:
8 src: "{{ item }}"
9 dest: "{{ galaxy_dir }}/requirements/{{ item }}"
10 loop:
11 - source_only.yml
12 - source_and_name.yml
13 - source_and_name_and_type.yml
14 - name_without_type.yml
15 - git_prefix_name.yml
16 - name_and_type.yml
17
18 - name: test source is not a git repo
19 command: 'ansible-galaxy collection install -r source_only.yml'
20 register: result
21 ignore_errors: true
22 args:
23 chdir: '{{ galaxy_dir }}/requirements'
24
25 - assert:
26 that:
27 - result.failed
28 - >-
29 "Neither the collection requirement entry key 'name',
30 nor 'source' point to a concrete resolvable collection artifact.
31 Also 'name' is not an FQCN. A valid collection name must be in
32 the format <namespace>.<collection>. Please make sure that the
33 namespace and the collection name contain characters from
34 [a-zA-Z0-9_] only." in result.stderr
35
36 - name: test source is not a git repo even if name is provided
37 command: 'ansible-galaxy collection install -r source_and_name.yml'
38 register: result
39 ignore_errors: true
40 args:
41 chdir: '{{ galaxy_dir }}/requirements'
42
43 - assert:
44 that:
45 - result.failed
46 - >-
47 result.stderr is search("Collections requirement 'source'
48 entry should contain a valid Galaxy API URL but it does not:
49 git\+file:///.*/amazon.aws/.git is not an HTTP URL.")
50
51 - name: test source is not a git repo even if name and type is provided
52 command: 'ansible-galaxy collection install -r source_and_name_and_type.yml'
53 register: result
54 ignore_errors: true
55 args:
56 chdir: '{{ galaxy_dir }}/requirements'
57
58 - assert:
59 that:
60 - result.failed
61 - >-
62 result.stderr is search("Failed to clone a Git repository
63 from `file:///.*/.git`.")
64 - >-
65 result.stderr is search("fatal: '/.*/amazon.aws/.git' does not
66 appear to be a git repository")
67
68 - name: test using name as a git repo without git+ prefix
69 command: 'ansible-galaxy collection install -r name_without_type.yml --no-deps'
70 register: result
71 ignore_errors: true
72 args:
73 chdir: '{{ galaxy_dir }}/requirements'
74
75 - assert:
76 that:
77 - result.failed
78 - '"name must be in the format <namespace>.<collection>" in result.stderr'
79
80 - name: Clone a git repository
81 git:
82 repo: https://github.com/ansible-collections/amazon.aws.git
83 dest: '{{ scm_path }}/amazon.aws/'
84
85 - name: test using name as a git repo
86 command: 'ansible-galaxy collection install -r git_prefix_name.yml --no-deps'
87 register: result
88 args:
89 chdir: '{{ galaxy_dir }}/requirements'
90
91 - name: test using name plus type as a git repo
92 command: 'ansible-galaxy collection install -r name_and_type.yml --force --no-deps'
93 register: result
94 args:
95 chdir: '{{ galaxy_dir }}/requirements'
96
97 - name: remove the test repo and requirements dir
98 file:
99 path: '{{ item }}'
100 state: absent
101 loop:
102 - '{{ scm_path }}/amazon.aws/'
103 - '{{ galaxy_dir }}/requirements'