From efc5d62c494d6a19364aabdd98ff1e38e3f43f58 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Tue, 11 Feb 2020 13:14:26 -0800 Subject: [PATCH] Use a custom test module for module_defaults test. This avoids a dependency on a module which will not remain in the repo after migration. --- lib/ansible/config/module_defaults.yml | 2 ++ .../library/test_module_defaults.py | 30 +++++++++++++++++ .../targets/module_defaults/tasks/main.yml | 32 ++++++++++--------- 3 files changed, 49 insertions(+), 15 deletions(-) create mode 100644 test/integration/targets/module_defaults/library/test_module_defaults.py diff --git a/lib/ansible/config/module_defaults.yml b/lib/ansible/config/module_defaults.yml index a47a967c840..d272592c779 100644 --- a/lib/ansible/config/module_defaults.yml +++ b/lib/ansible/config/module_defaults.yml @@ -1281,6 +1281,8 @@ groupings: - ovirt ovirt_vnic_profile: - ovirt + test_module_defaults: + - test vcenter_extension: - vmware vcenter_extension_info: diff --git a/test/integration/targets/module_defaults/library/test_module_defaults.py b/test/integration/targets/module_defaults/library/test_module_defaults.py new file mode 100644 index 00000000000..ede8c995607 --- /dev/null +++ b/test/integration/targets/module_defaults/library/test_module_defaults.py @@ -0,0 +1,30 @@ +#!/usr/bin/python +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +from ansible.module_utils.basic import AnsibleModule + + +def main(): + module = AnsibleModule( + argument_spec=dict( + arg1=dict(type='str', default='default1'), + arg2=dict(type='str', default='default2'), + arg3=dict(type='str', default='default3'), + ), + supports_check_mode=True + ) + + result = dict( + test_module_defaults=dict( + arg1=module.params['arg1'], + arg2=module.params['arg2'], + arg3=module.params['arg3'], + ), + ) + + module.exit_json(**result) + + +if __name__ == '__main__': + main() diff --git a/test/integration/targets/module_defaults/tasks/main.yml b/test/integration/targets/module_defaults/tasks/main.yml index 8661727cb36..b84e33f430e 100644 --- a/test/integration/targets/module_defaults/tasks/main.yml +++ b/test/integration/targets/module_defaults/tasks/main.yml @@ -89,26 +89,28 @@ foo.msg == "Hello world!" - name: Module group defaults block module_defaults: - group/aws: - region: us-east-1 - aws_secret_key: foobar + group/test: + arg1: "test1" + arg2: "test2" block: - - aws_s3_bucket_info: - ignore_errors: true - register: s3 + - test_module_defaults: + register: result - assert: that: - - "'Partial credentials' in s3.msg or 'boto3 required' in s3.msg" + - "result.test_module_defaults.arg1 == 'test1'" + - "result.test_module_defaults.arg2 == 'test2'" + - "result.test_module_defaults.arg3 == 'default3'" - name: Module group defaults block module_defaults: - group/aws: - region: us-east-1 - aws_secret_key: foobar - aws_access_key: foobar + group/test: + arg1: "test1" + arg2: "test2" + arg3: "test3" block: - - aws_s3_bucket_info: - ignore_errors: true - register: s3 + - test_module_defaults: + register: result - assert: that: - - "'InvalidAccessKeyId' in s3.msg or 'boto3 required' in s3.msg" + - "result.test_module_defaults.arg1 == 'test1'" + - "result.test_module_defaults.arg2 == 'test2'" + - "result.test_module_defaults.arg3 == 'test3'"