ansible/test/integration/targets/github_issue/tasks/main.yml
Abhijeet Kasurde a2c8481395 Add testcases for github_issue (#26309)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2017-08-30 14:50:45 -04:00

69 lines
2.1 KiB
YAML

# 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 }}"