ansible/test/integration/targets/ansible-galaxy-collection/tasks/download.yml
Jordan Borean a2deeb8fa2
ansible-galaxy - add download option (#67632)
* ansible-galaxy - add download option

* Fix sanity issues and added integration tests

* Fix doc suggestions

* Added --pre option
2020-03-25 08:32:43 +10:00

88 lines
4.3 KiB
YAML

---
- name: create test download dir
file:
path: '{{ galaxy_dir }}/download'
state: directory
- name: download collection with multiple dependencides
command: ansible-galaxy collection download parent_dep.parent_collection -s {{ fallaxy_galaxy_server }}
register: download_collection
args:
chdir: '{{ galaxy_dir }}/download'
- name: get result of download collection with multiple dependencies
find:
path: '{{ galaxy_dir }}/download/collections'
file_type: file
register: download_collection_actual
- name: assert download collection with multiple dependencies
assert:
that:
- '"Downloading collection ''parent_dep.parent_collection'' to" in download_collection.stdout'
- '"Downloading collection ''child_dep.child_collection'' to" in download_collection.stdout'
- '"Downloading collection ''child_dep.child_dep2'' to" in download_collection.stdout'
- download_collection_actual.examined == 4
- download_collection_actual.matched == 4
- (download_collection_actual.files[0].path | basename) in ['requirements.yml', 'child_dep-child_dep2-1.2.2.tar.gz', 'child_dep-child_collection-0.9.9.tar.gz', 'parent_dep-parent_collection-1.0.0.tar.gz']
- (download_collection_actual.files[1].path | basename) in ['requirements.yml', 'child_dep-child_dep2-1.2.2.tar.gz', 'child_dep-child_collection-0.9.9.tar.gz', 'parent_dep-parent_collection-1.0.0.tar.gz']
- (download_collection_actual.files[2].path | basename) in ['requirements.yml', 'child_dep-child_dep2-1.2.2.tar.gz', 'child_dep-child_collection-0.9.9.tar.gz', 'parent_dep-parent_collection-1.0.0.tar.gz']
- (download_collection_actual.files[3].path | basename) in ['requirements.yml', 'child_dep-child_dep2-1.2.2.tar.gz', 'child_dep-child_collection-0.9.9.tar.gz', 'parent_dep-parent_collection-1.0.0.tar.gz']
- name: test install of download requirements file
command: ansible-galaxy collection install -r requirements.yml -p '{{ galaxy_dir }}/download'
args:
chdir: '{{ galaxy_dir }}/download/collections'
register: install_download
- name: get result of test install of download requirements file
slurp:
path: '{{ galaxy_dir }}/download/ansible_collections/{{ collection.namespace }}/{{ collection.name }}/MANIFEST.json'
register: install_download_actual
loop_control:
loop_var: collection
loop:
- namespace: parent_dep
name: parent_collection
- namespace: child_dep
name: child_collection
- namespace: child_dep
name: child_dep2
- name: assert test install of download requirements file
assert:
that:
- '"Installing ''parent_dep.parent_collection:1.0.0'' to" in install_download.stdout'
- '"Installing ''child_dep.child_collection:0.9.9'' to" in install_download.stdout'
- '"Installing ''child_dep.child_dep2:1.2.2'' to" in install_download.stdout'
- (install_download_actual.results[0].content | b64decode | from_json).collection_info.version == '1.0.0'
- (install_download_actual.results[1].content | b64decode | from_json).collection_info.version == '0.9.9'
- (install_download_actual.results[2].content | b64decode | from_json).collection_info.version == '1.2.2'
- name: create test requirements file for download
copy:
content: |
collections:
- name: namespace1.name1
version: 1.1.0-beta.1
dest: '{{ galaxy_dir }}/download/download.yml'
- name: download collection with req to custom dir
command: ansible-galaxy collection download -r '{{ galaxy_dir }}/download/download.yml' -s {{ fallaxy_ah_server }} -p '{{ galaxy_dir }}/download/collections-custom'
register: download_req_custom_path
- name: get result of download collection with req to custom dir
find:
path: '{{ galaxy_dir }}/download/collections-custom'
file_type: file
register: download_req_custom_path_actual
- name: assert download collection with multiple dependencies
assert:
that:
- '"Downloading collection ''namespace1.name1'' to" in download_req_custom_path.stdout'
- download_req_custom_path_actual.examined == 2
- download_req_custom_path_actual.matched == 2
- (download_req_custom_path_actual.files[0].path | basename) in ['requirements.yml', 'namespace1-name1-1.1.0-beta.1.tar.gz']
- (download_req_custom_path_actual.files[1].path | basename) in ['requirements.yml', 'namespace1-name1-1.1.0-beta.1.tar.gz']