mirror of
https://github.com/ansible-collections/hetzner.hcloud
synced 2024-11-10 06:34:13 +00:00
test: check for api error code when possible (#486)
##### SUMMARY Ensure the error code is correct and replace the error message check in some cases.
This commit is contained in:
parent
7776905321
commit
8738f369d3
10 changed files with 31 additions and 15 deletions
|
@ -183,7 +183,7 @@
|
|||
ansible.builtin.assert:
|
||||
that:
|
||||
- result is failed
|
||||
- '"is still in use" in result.msg'
|
||||
- result.failure.code == "resource_in_use"
|
||||
|
||||
- name: Test delete with force
|
||||
hetzner.hcloud.firewall:
|
||||
|
|
|
@ -101,6 +101,7 @@
|
|||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- result.failure.code == "invalid_input"
|
||||
- result.msg == "invalid input in fields 'server', 'home_location'"
|
||||
|
||||
- name: test create Floating IP with check mode
|
||||
|
@ -371,7 +372,8 @@
|
|||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "Floating IP deletion is protected"'
|
||||
- result.failure.code == "protected"
|
||||
- result.msg == "Floating IP deletion is protected"
|
||||
|
||||
- name: test update Floating IP delete protection
|
||||
hetzner.hcloud.floating_ip:
|
||||
|
@ -459,7 +461,8 @@
|
|||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "Floating IP deletion is protected"'
|
||||
- result.failure.code == "protected"
|
||||
- result.msg == "Floating IP deletion is protected"
|
||||
|
||||
- name: test update Floating IP delete protection
|
||||
hetzner.hcloud.floating_ip:
|
||||
|
|
|
@ -120,7 +120,8 @@
|
|||
ansible.builtin.assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "load balancer deletion is protected"'
|
||||
- result.failure.code == "protected"
|
||||
- result.msg == "load balancer deletion is protected"
|
||||
|
||||
- name: Test update delete_protection
|
||||
hetzner.hcloud.load_balancer:
|
||||
|
|
|
@ -99,7 +99,8 @@
|
|||
ansible.builtin.assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "network deletion is protected"'
|
||||
- result.failure.code == "protected"
|
||||
- result.msg == "network deletion is protected"
|
||||
|
||||
- name: Test update delete protection
|
||||
hetzner.hcloud.network:
|
||||
|
|
|
@ -120,7 +120,8 @@
|
|||
ansible.builtin.assert:
|
||||
that:
|
||||
- result is failed
|
||||
- '"Primary IP deletion is protected" in result.msg'
|
||||
- result.failure.code == "protected"
|
||||
- result.msg == "Primary IP deletion is protected"
|
||||
|
||||
- name: Test update delete protection
|
||||
hetzner.hcloud.primary_ip:
|
||||
|
|
|
@ -315,7 +315,8 @@
|
|||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "server deletion is protected"'
|
||||
- result.failure.code == "protected"
|
||||
- result.msg == "server deletion is protected"
|
||||
|
||||
- name: test rebuild server fails if it is protected
|
||||
hetzner.hcloud.server:
|
||||
|
@ -328,7 +329,8 @@
|
|||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "server rebuild is protected"'
|
||||
- result.failure.code == "protected"
|
||||
- result.msg == "server rebuild is protected"
|
||||
|
||||
- name: test remove server protection
|
||||
hetzner.hcloud.server:
|
||||
|
@ -585,7 +587,8 @@
|
|||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "server deletion is protected"'
|
||||
- result.failure.code == "protected"
|
||||
- result.msg == "server deletion is protected"
|
||||
|
||||
- name: remove protection from server
|
||||
hetzner.hcloud.server:
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "firewall not-existing was not found"'
|
||||
- result.failure.code == "not_found"
|
||||
- result.msg == "firewall not-existing was not found"
|
||||
|
||||
- name: setup create firewalls
|
||||
hetzner.hcloud.firewall:
|
||||
name: "{{ item }}"
|
||||
|
|
|
@ -34,7 +34,8 @@
|
|||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "server_type not-existing-server-type was not found"'
|
||||
- result.failure.code == "not_found"
|
||||
- result.msg == "server_type not-existing-server-type was not found"
|
||||
|
||||
- name: test create server with not existing image
|
||||
hetzner.hcloud.server:
|
||||
|
@ -48,4 +49,5 @@
|
|||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "Image my-not-existing-image-20.04 was not found"'
|
||||
- result.failure.code == "not_found"
|
||||
- result.msg == "Image my-not-existing-image-20.04 was not found"
|
||||
|
|
|
@ -133,7 +133,8 @@
|
|||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "SSH key with the same fingerprint already exists"'
|
||||
- result.failure.code == "uniqueness_error"
|
||||
- result.msg == "SSH key with the same fingerprint already exists"
|
||||
|
||||
- name: test delete ssh key
|
||||
hetzner.hcloud.ssh_key:
|
||||
|
|
|
@ -208,7 +208,8 @@
|
|||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "volume deletion is protected"'
|
||||
- result.failure.code == "protected"
|
||||
- result.msg == "volume deletion is protected"
|
||||
|
||||
- name: test update Volume delete protection
|
||||
hetzner.hcloud.volume:
|
||||
|
@ -254,7 +255,8 @@
|
|||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- 'result.msg == "volume deletion is protected"'
|
||||
- result.failure.code == "protected"
|
||||
- result.msg == "volume deletion is protected"
|
||||
|
||||
- name: test update Volume delete protection
|
||||
hetzner.hcloud.volume:
|
||||
|
|
Loading…
Reference in a new issue