|
|
|
@ -91,84 +91,6 @@
|
|
|
|
|
- debug:
|
|
|
|
|
var: ansible_failed_result
|
|
|
|
|
|
|
|
|
|
- name: replace py version specific types with generic names so tests work on py2 and py3
|
|
|
|
|
set_fact:
|
|
|
|
|
# We want to compare if the actual failure messages and the expected failure messages
|
|
|
|
|
# are the same. But to compare and do set differences, we have to handle some
|
|
|
|
|
# differences between py2/py3.
|
|
|
|
|
# The validation failure messages include python type and class reprs, which are
|
|
|
|
|
# different between py2 and py3. For ex, "<type 'str'>" vs "<class 'str'>". Plus
|
|
|
|
|
# the usual py2/py3 unicode/str/bytes type shenanigans. The 'THE_FLOAT_REPR' is
|
|
|
|
|
# because py3 quotes the value in the error while py2 does not, so we just ignore
|
|
|
|
|
# the rest of the line.
|
|
|
|
|
actual_generic: "{{ ansible_failed_result.argument_errors|
|
|
|
|
|
map('replace', ansible_unicode_type_match, 'STR')|
|
|
|
|
|
map('replace', unicode_type_match, 'STR')|
|
|
|
|
|
map('replace', string_type_match, 'STR')|
|
|
|
|
|
map('replace', float_type_match, 'FLOAT')|
|
|
|
|
|
map('replace', list_type_match, 'LIST')|
|
|
|
|
|
map('replace', ansible_list_type_match, 'LIST')|
|
|
|
|
|
map('replace', dict_type_match, 'DICT')|
|
|
|
|
|
map('replace', ansible_dict_type_match, 'DICT')|
|
|
|
|
|
map('replace', ansible_unicode_class_match, 'STR')|
|
|
|
|
|
map('replace', unicode_class_match, 'STR')|
|
|
|
|
|
map('replace', string_class_match, 'STR')|
|
|
|
|
|
map('replace', bytes_class_match, 'STR')|
|
|
|
|
|
map('replace', float_class_match, 'FLOAT')|
|
|
|
|
|
map('replace', list_class_match, 'LIST')|
|
|
|
|
|
map('replace', ansible_list_class_match, 'LIST')|
|
|
|
|
|
map('replace', dict_class_match, 'DICT')|
|
|
|
|
|
map('replace', ansible_dict_class_match, 'DICT')|
|
|
|
|
|
map('regex_replace', '''float:.*$''', 'THE_FLOAT_REPR')|
|
|
|
|
|
map('regex_replace', 'Valid booleans include.*$', '')|
|
|
|
|
|
list }}"
|
|
|
|
|
expected_generic: "{{ expected.test1_1.argument_errors|
|
|
|
|
|
map('replace', ansible_unicode_type_match, 'STR')|
|
|
|
|
|
map('replace', unicode_type_match, 'STR')|
|
|
|
|
|
map('replace', string_type_match, 'STR')|
|
|
|
|
|
map('replace', float_type_match, 'FLOAT')|
|
|
|
|
|
map('replace', list_type_match, 'LIST')|
|
|
|
|
|
map('replace', ansible_list_type_match, 'LIST')|
|
|
|
|
|
map('replace', dict_type_match, 'DICT')|
|
|
|
|
|
map('replace', ansible_dict_type_match, 'DICT')|
|
|
|
|
|
map('replace', ansible_unicode_class_match, 'STR')|
|
|
|
|
|
map('replace', unicode_class_match, 'STR')|
|
|
|
|
|
map('replace', string_class_match, 'STR')|
|
|
|
|
|
map('replace', bytes_class_match, 'STR')|
|
|
|
|
|
map('replace', float_class_match, 'FLOAT')|
|
|
|
|
|
map('replace', list_class_match, 'LIST')|
|
|
|
|
|
map('replace', ansible_list_class_match, 'LIST')|
|
|
|
|
|
map('replace', dict_class_match, 'DICT')|
|
|
|
|
|
map('replace', ansible_dict_class_match, 'DICT')|
|
|
|
|
|
map('regex_replace', '''float:.*$''', 'THE_FLOAT_REPR')|
|
|
|
|
|
map('regex_replace', 'Valid booleans include.*$', '')|
|
|
|
|
|
list }}"
|
|
|
|
|
|
|
|
|
|
- name: figure out the difference between expected and actual validate_argument_spec failures
|
|
|
|
|
set_fact:
|
|
|
|
|
actual_not_in_expected: "{{ actual_generic| difference(expected_generic) | sort() }}"
|
|
|
|
|
expected_not_in_actual: "{{ expected_generic | difference(actual_generic) | sort() }}"
|
|
|
|
|
|
|
|
|
|
- name: assert that all actual validate_argument_spec failures were in expected
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- actual_not_in_expected | length == 0
|
|
|
|
|
msg: "Actual validate_argument_spec failures that were not expected: {{ actual_not_in_expected }}"
|
|
|
|
|
|
|
|
|
|
- name: assert that all expected validate_argument_spec failures were in expected
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- expected_not_in_actual | length == 0
|
|
|
|
|
msg: "Expected validate_argument_spec failures that were not in actual results: {{ expected_not_in_actual }}"
|
|
|
|
|
|
|
|
|
|
- name: assert that `validate_args_context` return value has what we expect
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- ansible_failed_result.validate_args_context.argument_spec_name == "main"
|
|
|
|
|
- ansible_failed_result.validate_args_context.name == "test1"
|
|
|
|
|
- ansible_failed_result.validate_args_context.type == "role"
|
|
|
|
|
- "ansible_failed_result.validate_args_context.path is search('roles_arg_spec/roles/test1')"
|
|
|
|
|
|
|
|
|
|
- name: test message for missing required parameters and invalid suboptions
|
|
|
|
|
block:
|
|
|
|
|
- include_role:
|
|
|
|
|