1
0
Fork 0
mirror of https://github.com/ansible-collections/hetzner.hcloud.git synced 2026-02-04 08:01:49 +00:00
hetzner.hcloud/tests/integration/targets/hcloud_location_info/tasks/test.yml
Jonas L 8b24cf2522
test: improve *_info modules tests (#299)
##### SUMMARY

- Implement the new testing framework (prepare.yml/cleanup.yml #239)
- Fix some uncovered test scenarios (related to #298).
- Structure all the *_info tests using the following structure:
  ```
  gather all
  [gather all with custom options...]
  gather all in check mode
  gather with id
  gather with name
  gather with labels
  [gather with custom option...]
  ```
2023-08-17 09:44:33 +02:00

56 lines
1.8 KiB
YAML

# Copyright: (c) 2019, Hetzner Cloud GmbH <info@hetzner-cloud.de>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
- name: Gather hcloud_location_info
hetzner.hcloud.hcloud_location_info:
register: result
- name: Verify hcloud_location_info
ansible.builtin.assert:
that:
- result.hcloud_location_info | list | count >= 5
- name: Gather hcloud_location_info in check mode
hetzner.hcloud.hcloud_location_info:
check_mode: true
register: result
- name: Verify hcloud_location_info in check mode
ansible.builtin.assert:
that:
- result.hcloud_location_info | list | count >= 5
- name: Gather hcloud_location_info with correct id
hetzner.hcloud.hcloud_location_info:
id: "{{ hcloud_location_id }}"
register: result
- name: Verify hcloud_location_info with correct id
ansible.builtin.assert:
that:
- result.hcloud_location_info | list | count == 1
- name: Gather hcloud_location_info with wrong id
hetzner.hcloud.hcloud_location_info:
id: "{{ hcloud_location_id }}4321"
ignore_errors: true
register: result
- name: Verify hcloud_location_info with wrong id
ansible.builtin.assert:
that:
- result is failed
- name: Gather hcloud_location_info with correct name
hetzner.hcloud.hcloud_location_info:
name: "{{ hcloud_location_name }}"
register: result
- name: Verify hcloud_location_info with correct name
ansible.builtin.assert:
that:
- result.hcloud_location_info | list | count == 1
- name: Gather hcloud_location_info with wrong name
hetzner.hcloud.hcloud_location_info:
name: "{{ hcloud_location_name }}-invalid"
register: result
- name: Verify hcloud_location_info with wrong name
ansible.builtin.assert:
that:
- result.hcloud_location_info | list | count == 0