From ba7097cba36ff700542d9d5e37570a293078cba8 Mon Sep 17 00:00:00 2001 From: Jordan Borean Date: Wed, 24 Jul 2019 12:38:32 +1000 Subject: [PATCH] Collection test (#59488) * Add missing __init__.py for collection unit tests * Added more tests for collection install and remove default path --- lib/ansible/cli/galaxy.py | 2 +- .../targets/ansible-galaxy/runme.sh | 25 +++++++++++++++++++ test/units/galaxy/__init__.py | 0 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 test/units/galaxy/__init__.py diff --git a/lib/ansible/cli/galaxy.py b/lib/ansible/cli/galaxy.py index b4a495037a7..4301f2d5f2e 100644 --- a/lib/ansible/cli/galaxy.py +++ b/lib/ansible/cli/galaxy.py @@ -118,7 +118,7 @@ class GalaxyCLI(CLI): cinstall_parser.add_argument('args', metavar='collection_name', nargs='*', help='The collection(s) name or path/url to a tar.gz collection artifact. This ' 'is mutually exclusive with --requirements-file.') - cinstall_parser.add_argument('-p', '--collections-path', dest='collections_path', default='./', + cinstall_parser.add_argument('-p', '--collections-path', dest='collections_path', required=True, help='The path to the directory containing your collections.') cinstall_parser.add_argument('-i', '--ignore-errors', dest='ignore_errors', action='store_true', default=False, help='Ignore errors during installation and continue with the next specified ' diff --git a/test/integration/targets/ansible-galaxy/runme.sh b/test/integration/targets/ansible-galaxy/runme.sh index 4e967ae62e6..63dc2e9917a 100755 --- a/test/integration/targets/ansible-galaxy/runme.sh +++ b/test/integration/targets/ansible-galaxy/runme.sh @@ -165,6 +165,31 @@ pushd "${galaxy_testdir}" [[ -f "${galaxy_testdir}/ansible_test-my_collection-1.0.0.tar.gz" ]] +f_ansible_galaxy_status \ + "collection install from local tarball test" + + ansible-galaxy collection install "ansible_test-my_collection-1.0.0.tar.gz" -p ./install | tee out.txt + + [[ -f "${galaxy_testdir}/install/ansible_collections/ansible_test/my_collection/MANIFEST.json" ]] + grep "Installing 'ansible_test.my_collection:1.0.0' to .*" out.txt + + +f_ansible_galaxy_status \ + "collection install with existing collection and without --force" + + ansible-galaxy collection install "ansible_test-my_collection-1.0.0.tar.gz" -p ./install | tee out.txt + + [[ -f "${galaxy_testdir}/install/ansible_collections/ansible_test/my_collection/MANIFEST.json" ]] + grep "Skipping 'ansible_test.my_collection' as it is already installed" out.txt + +f_ansible_galaxy_status \ + "collection install with existing collection and with --force" + + ansible-galaxy collection install "ansible_test-my_collection-1.0.0.tar.gz" -p ./install --force | tee out.txt + + [[ -f "${galaxy_testdir}/install/ansible_collections/ansible_test/my_collection/MANIFEST.json" ]] + grep "Installing 'ansible_test.my_collection:1.0.0' to .*" out.txt + popd # ${galaxy_testdir} rm -fr "${galaxy_testdir}" diff --git a/test/units/galaxy/__init__.py b/test/units/galaxy/__init__.py new file mode 100644 index 00000000000..e69de29bb2d