- name: check collections list from role meta
  plugin_lookup:
  register: pluginlookup_out

- name: call role-local ping module
  ping:
  register: ping_out

- name: call unqualified module in another collection listed in role meta (testns.coll_in_sys)
  systestmodule:
  register: systestmodule_out

# verify that pluginloader caching doesn't prevent us from explicitly calling a builtin plugin with the same name
- name: call builtin ping module explicitly
  ansible.builtin.ping:
  register: builtinping_out

- debug:
    msg: '{{ test_role_input | default("(undefined)") }}'
  register: test_role_output

- set_fact:
    testrole_source: collection

# FIXME: add tests to ensure that block/task level stuff in a collection-hosted role properly inherit role default/meta values

- assert:
    that:
    - pluginlookup_out.collection_list == ['testns.testcoll', 'ansible.builtin', 'testns.coll_in_sys', 'bogus.fromrolemeta']
    - ping_out.source is defined and ping_out.source == 'user'
    - systestmodule_out.source is defined and systestmodule_out.source == 'sys'
    - builtinping_out.ping is defined and builtinping_out.ping == 'pong'
    - test_role_input is not defined or test_role_input == test_role_output.msg
