1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

pkgng: test invalid annotate strings

Ensure that some likely to occur, invalid strings
given to the annotate module parameter 1. fail,
2. do not cause an exception, and 3. do not create
any actual annotations on packages.
This commit is contained in:
Ross Williams 2021-10-12 18:33:05 +00:00
parent b872b294fd
commit 8f013549fd

View file

@ -417,6 +417,37 @@
- pkgng_example9_add_annotation_old.changed
- '(pkgng_example9_add_annotation_old_verify.stdout_lines | select("match", "ansibletest_example9_[45]\s*:\s*added") | count) == 2'
##
## pkgng - example - invalid annotation strings
##
- name: Should fail on invalid annotate strings
pkgng:
name: '{{ pkgng_test_pkg_name }}'
annotation: '{{ item }}'
ignore_errors: yes
register: pkgng_example8_invalid_annotation_failure
loop:
- 'naked_string'
- '/invalid_operation'
- ',empty_first_tag=validsecond'
- '=notag'
- name: Verify invalid annotate strings did not add annotations
command: 'pkg info -q -A {{ pkgng_test_pkg_name }}'
register: pkgng_example8_invalid_annotation_verify
- name: Ensure invalid annotate strings fail safely
assert:
that:
# Invalid strings should not change anything
- '(pkgng_example8_invalid_annotation_failure.results | selectattr("changed") | count) == 0'
# Invalid strings should always fail
- '(pkgng_example8_invalid_annotation_failure.results | selectattr("failed", "false") | count) == 0'
# Invalid strings should not cause an exception
- '(pkgng_example8_invalid_annotation_failure.results | selectattr("exception", "defined") | count) == 0'
# Verify annotations are unaffected
- '(pkgng_example8_invalid_annotation_verify.stdout_lines | select("search", "(naked_string|invalid_operation|empty_first_tag|validsecond|notag)") | count) == 0'
##
## pkgng - example - Install single package in jail
##