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

90 lines
2.5 KiB
YAML
Raw Normal View History

- name: make a requirements directory
file:
state: directory
path: '{{ galaxy_dir }}/requirements'
- name: populate requirement templates
template:
src: "{{ item }}"
dest: "{{ galaxy_dir }}/requirements/{{ item }}"
loop:
- source_only.yml
- source_and_name.yml
- source_and_name_and_type.yml
- name_without_type.yml
- git_prefix_name.yml
- name_and_type.yml
- name: test source is not a git repo
command: 'ansible-galaxy collection install -r source_only.yml'
register: result
ignore_errors: true
args:
chdir: '{{ galaxy_dir }}/requirements'
- assert:
that:
- result.failed
- '"ERROR! Collections requirement entry should contain the key name." in result.stderr'
- name: test source is not a git repo even if name is provided
command: 'ansible-galaxy collection install -r source_and_name.yml'
register: result
ignore_errors: true
args:
chdir: '{{ galaxy_dir }}/requirements'
- assert:
that:
- result.failed
- '"ERROR! Unknown error when attempting to call Galaxy" in result.stderr'
- name: test source is not a git repo even if name and type is provided
command: 'ansible-galaxy collection install -r source_and_name_and_type.yml'
register: result
ignore_errors: true
args:
chdir: '{{ galaxy_dir }}/requirements'
- assert:
that:
- result.failed
- 'result.stderr is search("ERROR! - command /.*/git clone ansible.nope ansible.nope failed")'
- name: test using name as a git repo without git+ prefix
command: 'ansible-galaxy collection install -r name_without_type.yml'
register: result
ignore_errors: true
args:
chdir: '{{ galaxy_dir }}/requirements'
- assert:
that:
- result.failed
- '"name must be in the format <namespace>.<collection>" in result.stderr'
- name: Clone a git repository
git:
repo: https://github.com/ansible-collections/amazon.aws.git
dest: '{{ galaxy_dir }}/development/amazon.aws/'
- name: test using name as a git repo
command: 'ansible-galaxy collection install -r git_prefix_name.yml'
register: result
args:
chdir: '{{ galaxy_dir }}/requirements'
- name: test using name plus type as a git repo
command: 'ansible-galaxy collection install -r name_and_type.yml --force'
register: result
args:
chdir: '{{ galaxy_dir }}/requirements'
- name: remove the test repo and requirements dir
file:
path: '{{ item }}'
state: absent
loop:
- '{{ galaxy_dir }}/development/amazon.aws/'
- '{{ galaxy_dir }}/requirements'