mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 14:57:39 -02:30
Fix up the collection integration tests
This commit is contained in:
@@ -1,95 +1,115 @@
|
||||
---
|
||||
- name: Delete old git project from any previous test runs
|
||||
tower_project:
|
||||
name: "git project"
|
||||
organization: Default
|
||||
state: absent
|
||||
ignore_errors: true
|
||||
|
||||
- name: Create an SCM Credential
|
||||
tower_credential:
|
||||
name: SCM Credential for Project
|
||||
organization: Default
|
||||
kind: scm
|
||||
|
||||
- name: Create a Project
|
||||
- name: Create a git project without credentials without waiting
|
||||
tower_project:
|
||||
name: my-project
|
||||
organization: Default
|
||||
state: present
|
||||
scm_credential: SCM Credential for Project
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Delete a Project
|
||||
tower_project:
|
||||
name: my-project
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result is changed"
|
||||
|
||||
- name: Create a git project without credentials
|
||||
tower_project:
|
||||
name: git project
|
||||
name: "git project"
|
||||
organization: Default
|
||||
scm_type: git
|
||||
scm_url: https://github.com/ansible/ansible
|
||||
scm_url: https://github.com/ansible/test-playbooks
|
||||
wait: false
|
||||
register: result
|
||||
|
||||
- name: "Create {{ item }}"
|
||||
- assert:
|
||||
that:
|
||||
- result is changed
|
||||
|
||||
- name: Recreate the project to validate not changed
|
||||
tower_project:
|
||||
name: "git project"
|
||||
organization: Default
|
||||
scm_type: git
|
||||
scm_url: https://github.com/ansible/test-playbooks
|
||||
wait: true
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result is not changed
|
||||
|
||||
- name: Create organizations
|
||||
tower_organization:
|
||||
name: "{{ item }}"
|
||||
loop:
|
||||
- TestOrg1
|
||||
- TestOrg2
|
||||
name: TestOrg
|
||||
|
||||
- name: "Create credential"
|
||||
- name: Create credential
|
||||
tower_credential:
|
||||
kind: scm
|
||||
name: TestCred1
|
||||
organization: "{{ item }}"
|
||||
loop:
|
||||
- TestOrg2
|
||||
- TestOrg1
|
||||
name: TestCred
|
||||
organization: TestOrg
|
||||
|
||||
register: new_credentials
|
||||
|
||||
- name: Generate random project name appender
|
||||
set_fact:
|
||||
project_name_rand: "{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
|
||||
|
||||
- name: Create project TestProject
|
||||
- name: Create a new test project in check_mode
|
||||
tower_project:
|
||||
name: "TestProject {{ project_name_rand }}"
|
||||
organization: TestOrg1
|
||||
organization: TestOrg
|
||||
scm_type: git
|
||||
scm_url: "https://github.com/ansible/ansible"
|
||||
scm_credential: TestCred1
|
||||
register: multi_org_cred_project
|
||||
scm_url: https://github.com/ansible/test-playbooks
|
||||
scm_credential: TestCred
|
||||
check_mode: true
|
||||
|
||||
- name: Create a new test project
|
||||
tower_project:
|
||||
name: "TestProject {{ project_name_rand }}"
|
||||
organization: TestOrg
|
||||
scm_type: git
|
||||
scm_url: https://github.com/ansible/test-playbooks
|
||||
scm_credential: TestCred
|
||||
register: result
|
||||
|
||||
# If this fails it may be because the check_mode task actually already created
|
||||
# the project, or it could be because the module actually failed somehow
|
||||
- assert:
|
||||
that:
|
||||
- "multi_org_cred_project is changed"
|
||||
- "result is changed"
|
||||
|
||||
- name: Check module fails with correct msg
|
||||
- name: Check module fails with correct msg when given non-existing org as param
|
||||
tower_project:
|
||||
name: "TestProject {{ project_name_rand }}"
|
||||
organization: Non Existing Org
|
||||
scm_type: git
|
||||
scm_url: "https://github.com/ansible/ansible"
|
||||
scm_credential: TestCred1
|
||||
scm_url: https://github.com/ansible/test-playbooks
|
||||
scm_credential: TestCred
|
||||
register: result
|
||||
ignore_errors: true
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.msg == 'Failed to update project, organization not found: Non Existing Org'"
|
||||
- "result.msg == 'The organizations Non Existing Org was not found on the Tower server' or
|
||||
result.msg == 'Failed to update project, organization not found: Non Existing Org'"
|
||||
|
||||
- name: Check module fails with correct msg
|
||||
- name: Check module fails with correct msg when given non-existing credential as param
|
||||
tower_project:
|
||||
name: "TestProject {{ project_name_rand }}"
|
||||
organization: TestOrg1
|
||||
organization: TestOrg
|
||||
scm_type: git
|
||||
scm_url: "https://github.com/ansible/ansible"
|
||||
scm_url: https://github.com/ansible/test-playbooks
|
||||
scm_credential: Non Existing Credential
|
||||
register: result
|
||||
ignore_errors: true
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.msg =='Failed to update project, credential not found: Non Existing Credential'"
|
||||
- "result.msg =='The credentials Non Existing Credential was not found on the Tower server' or
|
||||
result.msg =='Failed to update project, credential not found: Non Existing Credential'"
|
||||
|
||||
- name: Delete the test project
|
||||
tower_project:
|
||||
name: "TestProject {{ project_name_rand }}"
|
||||
organization: TestOrg
|
||||
state: absent
|
||||
|
||||
Reference in New Issue
Block a user