Skip to content

Commit

Permalink
Add int tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tupyy committed Apr 22, 2024
1 parent 5ede7eb commit 4370c18
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/integration_source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,7 @@ jobs:
- name: Run configuration_item_relations integration tests
run: ansible-test integration configuration_item_relations
working-directory: ${{ steps.identify.outputs.collection_path }}

- name: Run service_catalog_info integration tests
run: ansible-test integration service_catalog_info
working-directory: ${{ steps.identify.outputs.collection_path }}
4 changes: 2 additions & 2 deletions plugins/module_utils/service_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def sys_id(self):

class Catalog(ServiceCatalogObject):
DISPLAY_FIELDS = ["sys_id", "description", "title",
"has_categories", "has_items", "categories", "items"]
"has_categories", "has_items", "categories", "sn_items"]
MANDATORY_FIELS = ["sys_id"]

def __init__(self, data=None):
Expand Down Expand Up @@ -87,7 +87,7 @@ def items(self, items):

def to_ansible(self):
self.data["categories"] = self.categories
self.data["items"] = self.items
self.data["sn_items"] = self.items
return super(Catalog, self).to_ansible()


Expand Down
55 changes: 55 additions & 0 deletions tests/integration/targets/service_catalog_info/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
- environment:
SN_HOST: "{{ sn_host }}"
SN_USERNAME: "{{ sn_username }}"
SN_PASSWORD: "{{ sn_password }}"

block:
- name: Get all catalogs
servicenow.itsm.service_catalog_info:
register: catalogs

- ansible.builtin.assert:
that:
- catalogs | length == 4

- name: Get one catalog only
servicenow.itsm.service_catalog_info:
categories: true
sys_id: "{{ catalogs.records[0].sys_id }}"
register: catalog

- ansible.builtin.assert:
that:
- catalog.records | length == 1
- catalog.records[0].categories | length > 0
- catalog.records[0].sn_items | length == 0

- name: Get one catalog with categoies and items
servicenow.itsm.service_catalog_info:
categories: true
items_info: brief
sys_id: "{{ catalogs.records[0].sys_id }}"
register: catalog

- ansible.builtin.assert:
that:
- catalog.records | length == 1
- catalog.records[0].categories | length > 0
- catalog.records[0].sn_items is defined
- catalog.records[0].sn_items | length > 0

- name: Get one catalog with categoies and items -- full info --
servicenow.itsm.service_catalog_info:
categories: true
items_info: full
sys_id: "{{ catalogs.records[0].sys_id }}"
register: catalog

- ansible.builtin.assert:
that:
- catalog.records | length == 1
- catalog.records[0].categories | length > 0
- catalog.records[0].sn_items is defined
- catalog.records[0].sn_items | length > 0
- catalog.records[0].sn_items[0].variables | length > 0

0 comments on commit 4370c18

Please sign in to comment.