Add testcases for github_issue (#26309)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
c9b74a3af3
commit
a2c8481395
4 changed files with 77 additions and 1 deletions
|
@ -103,7 +103,7 @@ def main():
|
|||
result = dict()
|
||||
|
||||
gh_obj = github3.issue(organization, repo, issue)
|
||||
if isinstance(gh_obj, github3.null.NullObject):
|
||||
if gh_obj is None:
|
||||
module.fail_json(msg="Failed to get details about issue specified. "
|
||||
"Please check organization, repo and issue "
|
||||
"details and try again.")
|
||||
|
|
1
test/integration/targets/github_issue/aliases
Normal file
1
test/integration/targets/github_issue/aliases
Normal file
|
@ -0,0 +1 @@
|
|||
posix/ci/group1
|
69
test/integration/targets/github_issue/tasks/main.yml
Normal file
69
test/integration/targets/github_issue/tasks/main.yml
Normal file
|
@ -0,0 +1,69 @@
|
|||
# Test code for the github_issue module.
|
||||
# (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
|
||||
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# Testcase 0001: Check if dependency is installed
|
||||
- name: Check if github3.py is installed or not
|
||||
github_issue:
|
||||
organization: "{{ organization }}"
|
||||
repo: "{{ repo }}"
|
||||
issue: "{{ non_existent_issue }}"
|
||||
action: get_status
|
||||
register: lib_missing
|
||||
ignore_errors: True
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "{{ lib_missing.failed == True }}"
|
||||
- "{{ lib_missing.changed == False }}"
|
||||
- "{{ 'Missing required github3 module.' in lib_missing.msg }}"
|
||||
|
||||
- name: make sure github3.py is installed
|
||||
pip:
|
||||
name: github3.py
|
||||
state: latest
|
||||
|
||||
# Testcase 0002: Check if issue exists
|
||||
- name: Check if GitHub issue is closed or not
|
||||
github_issue:
|
||||
organization: "{{ organization }}"
|
||||
repo: "{{ repo }}"
|
||||
issue: "{{ issue }}"
|
||||
action: get_status
|
||||
register: get_status_0002
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "{{ get_status_0002.changed == True }}"
|
||||
- "{{ get_status_0002.issue_status == 'closed' }}"
|
||||
|
||||
# Testcase 0003: Check non-existent issue status
|
||||
- name: Check if GitHub issue is closed or not
|
||||
github_issue:
|
||||
organization: "{{ organization }}"
|
||||
repo: "{{ repo }}"
|
||||
issue: "{{ non_existent_issue }}"
|
||||
action: get_status
|
||||
register: get_status_0003
|
||||
ignore_errors: True
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "{{ get_status_0003.changed == False }}"
|
||||
- "{{ get_status_0003.failed == True }}"
|
||||
- "{{ 'Failed' in get_status_0003.msg }}"
|
6
test/integration/targets/github_issue/vars/main.yml
Normal file
6
test/integration/targets/github_issue/vars/main.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
|
||||
issue: 23642
|
||||
non_existent_issue: 1111111
|
||||
organization: ansible
|
||||
repo: ansible
|
Loading…
Reference in a new issue