987265a6ef
Improve tests - add more unit test cases - add specific integration test with more cases Testing shows no major downside to calling .strip() twice in a comprehension vs. using a regular for loop and only calling .strip() once. Going with the comprehension for ease of maintenance and because comprehensions are optimized in CPython.
31 lines
1.3 KiB
Bash
Executable file
31 lines
1.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
set -eux
|
|
|
|
trap 'echo "Host pattern limit test failed"' ERR
|
|
|
|
# https://github.com/ansible/ansible/issues/61964
|
|
|
|
# These tests should return all hosts
|
|
ansible -i hosts.yml all --limit ,, --list-hosts | tee out ; grep -q 'hosts (3)' out
|
|
ansible -i hosts.yml ,, --list-hosts | tee out ; grep -q 'hosts (3)' out
|
|
ansible -i hosts.yml , --list-hosts | tee out ; grep -q 'hosts (3)' out
|
|
ansible -i hosts.yml all --limit , --list-hosts | tee out ; grep -q 'hosts (3)' out
|
|
ansible -i hosts.yml all --limit '' --list-hosts | tee out ; grep -q 'hosts (3)' out
|
|
|
|
|
|
# Only one host
|
|
ansible -i hosts.yml all --limit ,,host1 --list-hosts | tee out ; grep -q 'hosts (1)' out
|
|
ansible -i hosts.yml ,,host1 --list-hosts | tee out ; grep -q 'hosts (1)' out
|
|
|
|
ansible -i hosts.yml all --limit host1,, --list-hosts | tee out ; grep -q 'hosts (1)' out
|
|
ansible -i hosts.yml host1,, --list-hosts | tee out ; grep -q 'hosts (1)' out
|
|
|
|
|
|
# Only two hosts
|
|
ansible -i hosts.yml all --limit host1,,host3 --list-hosts | tee out ; grep -q 'hosts (2)' out
|
|
ansible -i hosts.yml host1,,host3 --list-hosts | tee out ; grep -q 'hosts (2)' out
|
|
|
|
ansible -i hosts.yml all --limit 'host1, , ,host3' --list-hosts | tee out ; grep -q 'hosts (2)' out
|
|
ansible -i hosts.yml 'host1, , ,host3' --list-hosts | tee out ; grep -q 'hosts (2)' out
|
|
|