Files
awx/awx_collection/tests/integration/targets/team/tasks/main.yml
Lila Yasin cd12f4dcac Update Collections Syntax to get Collection related CI Checks Passing (#16061)
* Fix collection task breaking collection ci checks

* Patch ansible.module_utils.basic._ANSIBLE_PROFILE directly

* Conditionalize other santity assertions

* Remove added blank lines and identifier from Fail if absent and no identifier set
2025-08-06 14:56:21 -04:00

109 lines
2.4 KiB
YAML

---
- name: Generate a test ID
ansible.builtin.set_fact:
test_id: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
when: test_id is not defined
- name: Generate names
ansible.builtin.set_fact:
team_name: "AWX-Collection-tests-team-team-{{ test_id }}"
- name: Attempt to add a team to a non-existant Organization
team:
name: Test Team
organization: Missing_Organization
state: present
register: result
ignore_errors: true
- name: Assert a meaningful error was provided for the failed team creation
ansible.builtin.assert:
that:
- "result is failed"
- >-
'Missing_Organization' in result.msg
- name: Create a team
team:
name: "{{ team_name }}"
organization: Default
register: result
- name: Assert result changed
ansible.builtin.assert:
that:
- result.changed
- name: Create a team with exists
team:
name: "{{ team_name }}"
organization: Default
state: exists
register: result
- name: Assert result did not change
ansible.builtin.assert:
that:
- not result.changed
- name: Delete a team
team:
name: "{{ team_name }}"
organization: Default
state: absent
register: result
- name: Assert reesult changed
ansible.builtin.assert:
that:
- result.changed
- name: Create a team with exists
team:
name: "{{ team_name }}"
organization: Default
state: exists
register: result
- name: Assert result changed
ansible.builtin.assert:
that:
- result.changed
- name: Delete a team
team:
name: "{{ team_name }}"
organization: Default
state: absent
register: result
- name: Assert result changed
ansible.builtin.assert:
that:
- result.changed
- name: Check module fails with correct msg
team:
name: "{{ team_name }}"
organization: Non_Existing_Org
state: present
register: result
ignore_errors: true
- name: Assert module failed with expected message
ansible.builtin.assert:
that:
- "result is failed"
- >-
'returned 0 items, expected 1' in result.msg or
'returned 0 items, expected 1' in result.exception or
'returned 0 items, expected 1' in result.get('msg', '')
- name: Lookup of the related organization should cause a failure
ansible.builtin.assert:
that:
- result.failed
- not result.changed
- "'Non_Existing_Org' in result.msg"
- "result.total_results == 0"