Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/gitlab_issue/tasks/main.yml

raw
1 ---
2 ####################################################################
3 # WARNING: These are designed specifically for Ansible tests #
4 # and should not be used as examples of how to write Ansible roles #
5 ####################################################################
6
7 # Copyright (c) Ansible Project
8 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
9 # SPDX-License-Identifier: GPL-3.0-or-later
10
11 - name: Install required libs
12 pip:
13 name: python-gitlab
14 state: present
15
16 - block:
17 - name: Create {{ gitlab_project_name }} project
18 gitlab_project:
19 api_url: "{{ gitlab_host }}"
20 validate_certs: true
21 api_token: "{{ gitlab_api_token }}"
22 name: "{{ gitlab_project_name }}"
23 group: "{{ gitlab_project_group }}"
24 default_branch: "{{ gitlab_branch }}"
25 initialize_with_readme: true
26 state: present
27
28 - name: Create Issue
29 gitlab_issue:
30 api_token: "{{ gitlab_api_token }}"
31 api_url: "{{ gitlab_host }}"
32 description: "Test description"
33 project: "{{ gitlab_project_group }}/{{ gitlab_project_name }}"
34 state: present
35 title: "Ansible test issue"
36 register: gitlab_issue_create
37
38 - name: Test Issue Created
39 assert:
40 that:
41 - gitlab_issue_create is changed
42
43 - name: Create Issue ( Idempotency test )
44 gitlab_issue:
45 api_token: "{{ gitlab_api_token }}"
46 api_url: "{{ gitlab_host }}"
47 description: "Test description"
48 project: "{{ gitlab_project_group }}/{{ gitlab_project_name }}"
49 state: present
50 title: "Ansible test issue"
51 register: gitlab_issue_create_idempotence
52
53 - name: Test Create Issue is Idempotent
54 assert:
55 that:
56 - gitlab_issue_create_idempotence is not changed
57
58 - name: Update Issue Test ( Additions )
59 gitlab_issue:
60 api_token: "{{ gitlab_api_token }}"
61 api_url: "{{ gitlab_host }}"
62 assignee_ids: "{{ gitlab_assignee_ids }}"
63 description_path: "{{ gitlab_description_path }}"
64 labels: "{{ gitlab_labels }}"
65 milestone_search: "{{ gitlab_milestone_search }}"
66 milestone_group_id: "{{ gitlab_milestone_group_id }}"
67 project: "{{ gitlab_project_group }}/{{ gitlab_project_name }}"
68 state: present
69 title: "Ansible test issue"
70 register: gitlab_issue_update_additions
71
72 - name: Test Issue Updated ( Additions )
73 assert:
74 that:
75 - gitlab_issue_update_additions.issue.labels[0] == "{{ gitlab_labels[0] }}"
76 - gitlab_issue_update_additions.issue.assignees[0].username == "{{ gitlab_assignee_ids[0] }}"
77 - "'### Description\n\nIssue test description' in gitlab_issue_update_additions.issue.description"
78 - gitlab_issue_update_additions.issue.milestone.title == "{{ gitlab_milestone_search }}"
79
80 - name: Update Issue Test ( Persistence )
81 gitlab_issue:
82 api_token: "{{ gitlab_api_token }}"
83 api_url: "{{ gitlab_host }}"
84 description_path: "{{ gitlab_description_path }}"
85 milestone_search: "{{ gitlab_milestone_search }}"
86 milestone_group_id: "{{ gitlab_milestone_group_id }}"
87 project: "{{ gitlab_project_group }}/{{ gitlab_project_name }}"
88 state: present
89 title: "Ansible test issue"
90 register: gitlab_issue_update_persistence
91
92 - name: Test issue Not Updated ( Persistence )
93 assert:
94 that:
95 - gitlab_issue_update_persistence.issue.labels[0] == "{{ gitlab_labels[0] }}"
96 - gitlab_issue_update_persistence.issue.assignees[0].username == "{{ gitlab_assignee_ids[0] }}"
97
98 - name: Update Issue Test ( Removals )
99 gitlab_issue:
100 api_token: "{{ gitlab_api_token }}"
101 api_url: "{{ gitlab_host }}"
102 assignee_ids: []
103 description_path: "{{ gitlab_description_path }}"
104 labels: []
105 milestone_search: ""
106 milestone_group_id: ""
107 project: "{{ gitlab_project_group }}/{{ gitlab_project_name }}"
108 state: present
109 title: "Ansible test issue"
110 register: gitlab_issue_update_removal
111
112 - name: Test issue updated
113 assert:
114 that:
115 - gitlab_issue_update_removal.issue.labels == []
116 - gitlab_issue_update_removal.issue.assignees == []
117 - gitlab_issue_update_removal.issue.milestone == None
118
119 - name: Delete Issue
120 gitlab_issue:
121 api_url: "{{ gitlab_host }}"
122 api_token: "{{ gitlab_api_token }}"
123 project: "{{ gitlab_project_group }}/{{ gitlab_project_name }}"
124 title: "Ansible test issue"
125 state: absent
126 register: gitlab_issue_delete
127
128 - name: Test issue is deleted
129 assert:
130 that:
131 - gitlab_issue_delete is changed
132
133 always:
134 - name: Delete Issue
135 gitlab_issue:
136 api_url: "{{ gitlab_host }}"
137 api_token: "{{ gitlab_api_token }}"
138 project: "{{ gitlab_project_group }}/{{ gitlab_project_name }}"
139 title: "Ansible test issue"
140 state_filter: "opened"
141 state: absent
142 register: gitlab_issue_delete
143 - name: Clean up {{ gitlab_project_name }}
144 gitlab_project:
145 api_url: "{{ gitlab_host }}"
146 validate_certs: false
147 api_token: "{{ gitlab_api_token }}"
148 name: "{{ gitlab_project_name }}"
149 group: "{{ gitlab_project_group }}"
150 state: absent