Add a couple more tests to ansible-galaxy-collection (#72931)

* Test installing a dependency compatible with multiple collection requirements

Test downloading a collection without dependencies

* Move cleanup to the end of the test suite
This commit is contained in:
Sloane Hertel 2020-12-10 11:26:50 -05:00 committed by GitHub
parent a3b6485073
commit 0a60e5e341
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 5 deletions

View file

@ -4,6 +4,29 @@
path: '{{ galaxy_dir }}/download'
state: directory
- name: download collection with multiple dependencies with --no-deps
command: ansible-galaxy collection download parent_dep.parent_collection --no-deps -s pulp_v2 {{ galaxy_verbosity }}
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'
- 'not "Downloading collection ''child_dep.child_collection'' to" in download_collection.stdout'
- 'not "Downloading collection ''child_dep.child_dep2'' to" in download_collection.stdout'
- download_collection_actual.examined == 2
- download_collection_actual.matched == 2
- (download_collection_actual.files[0].path | basename) in ['requirements.yml', 'parent_dep-parent_collection-1.0.0.tar.gz']
- (download_collection_actual.files[1].path | basename) in ['requirements.yml', 'parent_dep-parent_collection-1.0.0.tar.gz']
- name: download collection with multiple dependencies
command: ansible-galaxy collection download parent_dep.parent_collection -s pulp_v2 {{ galaxy_verbosity }}
register: download_collection

View file

@ -335,11 +335,6 @@
# - '"Installing ''cache.cache:1.0.{{ cache_version_build }}'' to" in install_cached_update.stdout'
# - (install_cached_update_actual.content | b64decode | from_json).collection_info.version == '1.0.' ~ cache_version_build
- name: remove test collection install directory - {{ test_name }}
file:
path: '{{ galaxy_dir }}/ansible_collections'
state: absent
- name: install collection with symlink - {{ test_name }}
command: ansible-galaxy collection install symlink.symlink -s '{{ test_name }}' {{ galaxy_verbosity }}
environment:
@ -380,3 +375,26 @@
- install_symlink_actual.results[4].stat.lnk_target == 'docs'
- install_symlink_actual.results[5].stat.islnk
- install_symlink_actual.results[5].stat.lnk_target == '../REÅDMÈ.md'
- name: remove install directory for the next test because parent_dep.parent_collection was installed - {{ test_name }}
file:
path: '{{ galaxy_dir }}/ansible_collections'
state: absent
- name: install collection and dep compatible with multiple requirements - {{ test_name }}
command: ansible-galaxy collection install parent_dep.parent_collection parent_dep2.parent_collection
environment:
ANSIBLE_COLLECTIONS_PATHS: '{{ galaxy_dir }}/ansible_collections'
register: install_req
- name: assert install collections with ansible-galaxy install - {{ test_name }}
assert:
that:
- '"Installing ''parent_dep.parent_collection:1.0.0'' to" in install_req.stdout'
- '"Installing ''parent_dep2.parent_collection:1.0.0'' to" in install_req.stdout'
- '"Installing ''child_dep.child_collection:0.5.0'' to" in install_req.stdout'
- name: remove test collection install directory - {{ test_name }}
file:
path: '{{ galaxy_dir }}/ansible_collections'
state: absent

View file

@ -75,6 +75,10 @@ collection_list:
name: parent_collection
dependencies:
child_dep.child_collection: '>=0.5.0,<1.0.0'
- namespace: parent_dep2
name: parent_collection
dependencies:
child_dep.child_collection: '0.5.0'
- namespace: child_dep
name: child_collection
version: 0.4.0