Skip to content

Commit

Permalink
fix: removing curly braces from ansible test asserts, it's considered…
Browse files Browse the repository at this point in the history
  • Loading branch information
t0mk committed Feb 15, 2024
1 parent 48d6acd commit 8aae992
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 56 deletions.
8 changes: 4 additions & 4 deletions tests/integration/targets/metal_connection/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@

- assert:
that:
- test_connection.name == "{{ test_name }}"
- test_connection.id == "{{ test_connection_fetched.id }}"
- test_connection.id == "{{ test_connection_fetched_with_id.id }}"
- test_connection.name == test_name
- test_connection.id == test_connection_fetched.id
- test_connection.id == test_connection_fetched_with_id.id

- name: list test connections
equinix.cloud.metal_connection_info:
Expand All @@ -108,7 +108,7 @@
- assert:
that:
- "test_connections_list.resources | length >= 1"
- "test_connection.id in {{ test_connections_list.resources | map(attribute='id') | list }} "
- "test_connection.id in test_connections_list.resources | map(attribute='id') | list"

- name: delete connection
equinix.cloud.metal_connection:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/targets/metal_gateway/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

- assert:
that:
- fetched_gateway.id == "{{ gateway.id }}"
- fetched_gateway.id == gateway.id

- name: list gateways
equinix.cloud.metal_gateway_info:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

- assert:
that:
- gateway_again.id == "{{ gateway.id }}"
- gateway_again.id == gateway.id
- gateway_again.changed == false

- name: fetch gateway by id
Expand All @@ -69,9 +69,9 @@

- assert:
that:
- fetched_gateway.id == "{{ gateway.id }}"
- fetched_gateway.ip_reservation_id == "{{ ip_reservation.id }}"
- fetched_gateway.virtual_network_id == "{{ vlan.id }}"
- fetched_gateway.id == gateway.id
- fetched_gateway.ip_reservation_id == ip_reservation.id
- fetched_gateway.virtual_network_id == vlan.id

- name: delete gateway
equinix.cloud.metal_gateway:
Expand Down
8 changes: 2 additions & 6 deletions tests/integration/targets/metal_ip_assignment/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
name: "{{ test_prefix }}-project"
register: project

- assert:
that:
- project.name == '{{ test_prefix }}-project'

- name: request ip reservation
equinix.cloud.metal_reserved_ip_block:
type: "public_ipv4"
Expand Down Expand Up @@ -77,8 +73,8 @@

- assert:
that:
- assignment.device_id == "{{ device.id }}"
- assignment.address == "{{ available_ips.available[0] }}"
- assignment.device_id == device.id
- assignment.address == available_ips.available[0]

- name: assignment info test
equinix.cloud.metal_ip_assignment_info:
Expand Down
21 changes: 14 additions & 7 deletions tests/integration/targets/metal_project/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,36 @@
unique_id: "{{ lookup('password', '/dev/null chars=ascii_lowercase,digits length=8') }}"
- set_fact:
test_prefix: "{{ test_resource_name_prefix }}-{{ unique_id }}"
- set_fact:
test_project_name1: '{{ test_prefix }}-project1'
- set_fact:
test_project_renamed: '{{ test_prefix }}-project1_renamed'
- set_fact:
test_project_name2: '{{ test_prefix }}-project2'


- name: create first project for test
equinix.cloud.metal_project:
name: "{{ test_prefix }}-project1"
name: "{{ test_project_name1 }}"
backend_transfer_enabled: true
register: first_project

- name: create first project for test again, to check idempotence
equinix.cloud.metal_project:
name: "{{ test_prefix }}-project1"
name: "{{ test_project_name1 }}"
backend_transfer_enabled: true
register: first_project_2

- assert:
that:
- first_project.name == '{{ test_prefix }}-project1'
- first_project.name == test_project_name1
- first_project.backend_transfer_enabled == true
- first_project_2.changed == false

- name: update project name
equinix.cloud.metal_project:
id: "{{ first_project.id }}"
name: "{{ test_prefix }}-project1_renamed"
name: "{{ test_project_renamed }}"
backend_transfer_enabled: false

- name: fetch updated project
Expand All @@ -45,17 +52,17 @@

- assert:
that:
- first_project_updated.name == '{{ test_prefix }}-project1_renamed'
- first_project_updated.name == test_project_renamed
- first_project_updated.backend_transfer_enabled == false

- name: create second project for test
equinix.cloud.metal_project:
name: "{{ test_prefix }}-project2"
name: "{{ test_project_name2 }}"
register: second_project

- name: list second project
equinix.cloud.metal_project_info:
name: "{{ test_prefix }}-project2"
name: "{{ test_project_name2 }}"
register: second_project_listed

- assert:
Expand Down
29 changes: 16 additions & 13 deletions tests/integration/targets/metal_project_ssh_key/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,37 @@
test_key: "ssh-dss AAAAB3NzaC1kc3MAAACBAOpXVtmc0Bla98bt0o5/Zj7sb4mHIukgVFZu7F32R3VK1cEKB4rEE8uS0oLS/qMRLue45TWVJwRMYGlPjt3p/VyraelxoyJZLuITIsqa5hBc9w0oTlB5Bmbkn16umW96WCaWEoq/aitpocbRChTiP5biI6FyQTQlIHDaYzBDOi11AAAAFQDUXy7cmuzphDpJSYYTiudiUhVokwAAAIEAyUQ9m8qL/1HPkFe6jbXAvtSSmW27F4c+G2xR5HizaHQzXgBOxPcsOsY17KTU+Ddbg+OF9soWNwSpm9pyVjVmNGqH3S8R1pwvuJF/O2Asy1m6wpWhbPw8JdEBW7WHoptBpfuzJoS2LOzJUEmUu4Eb+xS237KG1d1BVny/49KAoH0AAACBAJKBSsm9Xey0fUN6vYtTQgoYeGxxj/LqAIAOs/TpCxZDntly860y/SzHYai8x48k4t7whENY1CJ41fpMcPlz8xIsrNP3326Wbr0ExwOIvJKAVN1YLYqF8NXWzaVrjo5WbSeI8PiWTYemvLAujVxZssIrApTZBhp55nnwge6K1zTG tomk@air"
- set_fact:
test_key2: "ssh-dss AAAAB3NzaC1kc3MAAACBAPWcHWkA06LxBQ67WmNsp1+aZMwNNz9v67pftePlQg94Z1cU4s/5j5S/Fknj7gapWw/ouiOYqXhC2p/hC9/1ARY15t0aHYqLjRhWzs3j8miL1YyXYjqLPLDtgNpX9E09We5ogjbYCB8CCtZrujm/MB6NWvX+T4uG8C/g66I4/bGdAAAAFQDa4SS+q9aQK/XwiqnWpFpAEY74TQAAAIEAklEfXCf1qbUvTquHhtNVKTiKm+qGRsqxnLnu7aduzU81JDFzveF/agkE5x30olTvKECb1PAziDmt63z/obO3Da8TUz0QVdqv81pNWU5JUNiTB8d3rDJU3B66DA6GI305W8qyt0AGUNGR3rDIzNpZY958faBg+TaILRg8ZFNh0PAAAACAdUhJS6bl5M5sQr6XNilHa0nOTk/PB54faGWWMq7zQvxUKJKsDklNTc0MCPjRppyuokbQ6297tq8pEEFqUAyllMvAf75X7DsBQivLzbNuzp41NqFdS/Oka+T1ypRD7mT6g0Kg8yCVYD2ti874wyTpV9riUUaoItveEF3AdC9AzmI= tomk@air"
- set_fact:
test_key_label: "{{ test_prefix }}-ssh_key1"
- set_fact:
test_key_renamed: "{{ test_prefix }}-ssh_key1_renamed"
- set_fact:
test_key_label2: "{{ test_prefix }}-ssh_key2"

- name: create project for test
equinix.cloud.metal_project:
name: "{{ test_prefix }}-project"
register: project

- assert:
that:
- project.name == '{{ test_prefix }}-project'

- name: create first project ssh_key for test
equinix.cloud.metal_project_ssh_key:
label: "{{ test_prefix }}-ssh_key1"
key: "{{ test_key }}"
project_id: "{{ project.id }}"
register: first_ssh_key


- name: create first ssh_key for test again, to check idempotence
equinix.cloud.metal_project_ssh_key:
label: "{{ test_prefix }}-ssh_key1"
label: "{{ test_key_label }}"
key: "{{ test_key }}"
project_id: "{{ project.id }}"
register: first_ssh_key_2

- assert:
that:
- first_ssh_key.label == '{{ test_prefix }}-ssh_key1'
- first_ssh_key.key == "{{ test_key }}"
- first_ssh_key.label == test_key_label
- first_ssh_key.key == test_key
- first_ssh_key_2.changed == false

- name: update ssh_key label
Expand All @@ -65,12 +68,12 @@

- assert:
that:
- first_ssh_key_updated.label == '{{ test_prefix }}-ssh_key1_renamed'
- first_ssh_key.key == "{{ test_key }}"
- first_ssh_key_updated.label == test_key_renamed
- first_ssh_key.key == test_key

- name: create second ssh_key for test
equinix.cloud.metal_project_ssh_key:
label: "{{ test_prefix }}-ssh_key2"
label: "{{ test_key_label2 }}"
key: "{{ test_key2 }}"
project_id: "{{ project.id }}"
register: second_ssh_key
Expand All @@ -84,11 +87,11 @@
msg: "{{ ssh_keys_listed.resources }}"

- debug:
msg: 'ssh_keys_listed.resources | selectattr("label", "equalto", "{{ test_prefix }}-ssh_key2")'
msg: 'ssh_keys_listed.resources | selectattr("label", "equalto", test_key_label2)'

- assert:
that:
- 'ssh_keys_listed.resources | selectattr("label", "equalto", "{{ test_prefix }}-ssh_key2") | length == 1'
- 'ssh_keys_listed.resources | selectattr("label", "equalto", test_key_label2) | length == 1'

- name: list test ssh keys
set_fact:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
name: "{{ test_prefix }}-project"
register: project

- assert:
that:
- project.name == '{{ test_prefix }}-project'

- name: request ip reservation
equinix.cloud.metal_reserved_ip_block:
type: "public_ipv4"
Expand Down
26 changes: 16 additions & 10 deletions tests/integration/targets/metal_ssh_key/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,36 @@
test_key: "ssh-dss AAAAB3NzaC1kc3MAAACBAOpXVtmc0Bla98bt0o5/Zj7sb4mHIukgVFZu7F32R3VK1cEKB4rEE8uS0oLS/qMRLue45TWVJwRMYGlPjt3p/VyraelxoyJZLuITIsqa5hBc9w0oTlB5Bmbkn16umW96WCaWEoq/aitpocbRChTiP5biI6FyQTQlIHDaYzBDOi11AAAAFQDUXy7cmuzphDpJSYYTiudiUhVokwAAAIEAyUQ9m8qL/1HPkFe6jbXAvtSSmW27F4c+G2xR5HizaHQzXgBOxPcsOsY17KTU+Ddbg+OF9soWNwSpm9pyVjVmNGqH3S8R1pwvuJF/O2Asy1m6wpWhbPw8JdEBW7WHoptBpfuzJoS2LOzJUEmUu4Eb+xS237KG1d1BVny/49KAoH0AAACBAJKBSsm9Xey0fUN6vYtTQgoYeGxxj/LqAIAOs/TpCxZDntly860y/SzHYai8x48k4t7whENY1CJ41fpMcPlz8xIsrNP3326Wbr0ExwOIvJKAVN1YLYqF8NXWzaVrjo5WbSeI8PiWTYemvLAujVxZssIrApTZBhp55nnwge6K1zTG tomk@air"
- set_fact:
test_key2: "ssh-dss AAAAB3NzaC1kc3MAAACBAPWcHWkA06LxBQ67WmNsp1+aZMwNNz9v67pftePlQg94Z1cU4s/5j5S/Fknj7gapWw/ouiOYqXhC2p/hC9/1ARY15t0aHYqLjRhWzs3j8miL1YyXYjqLPLDtgNpX9E09We5ogjbYCB8CCtZrujm/MB6NWvX+T4uG8C/g66I4/bGdAAAAFQDa4SS+q9aQK/XwiqnWpFpAEY74TQAAAIEAklEfXCf1qbUvTquHhtNVKTiKm+qGRsqxnLnu7aduzU81JDFzveF/agkE5x30olTvKECb1PAziDmt63z/obO3Da8TUz0QVdqv81pNWU5JUNiTB8d3rDJU3B66DA6GI305W8qyt0AGUNGR3rDIzNpZY958faBg+TaILRg8ZFNh0PAAAACAdUhJS6bl5M5sQr6XNilHa0nOTk/PB54faGWWMq7zQvxUKJKsDklNTc0MCPjRppyuokbQ6297tq8pEEFqUAyllMvAf75X7DsBQivLzbNuzp41NqFdS/Oka+T1ypRD7mT6g0Kg8yCVYD2ti874wyTpV9riUUaoItveEF3AdC9AzmI= tomk@air"
- set_fact:
test_key_label: "{{ test_prefix }}-ssh_key1"
- set_fact:
test_key_label2: "{{ test_prefix }}-ssh_key2"
- set_fact:
test_key_renamed: "{{ test_prefix }}-ssh_key1_renamed"

- name: create first ssh_key for test
equinix.cloud.metal_ssh_key:
label: "{{ test_prefix }}-ssh_key1"
label: "{{ test_key_label }}"
key: "{{ test_key }}"
register: first_ssh_key

- name: create first ssh_key for test again, to check idempotence
equinix.cloud.metal_ssh_key:
label: "{{ test_prefix }}-ssh_key1"
label: "{{ test_key_label }}"
key: "{{ test_key }}"
register: first_ssh_key_2

- assert:
that:
- first_ssh_key.label == '{{ test_prefix }}-ssh_key1'
- first_ssh_key.key == "{{ test_key }}"
- first_ssh_key.label == test_key_label
- first_ssh_key.key == test_key
- first_ssh_key_2.changed == false

- name: update ssh_key name
equinix.cloud.metal_ssh_key:
id: "{{ first_ssh_key.id }}"
key: "{{ test_key }}"
label: "{{ test_prefix }}-ssh_key1_renamed"
label: "{{ test_key_renamed }}"

- name: fetch updated ssh_key
equinix.cloud.metal_ssh_key:
Expand All @@ -49,12 +55,12 @@

- assert:
that:
- first_ssh_key_updated.label == '{{ test_prefix }}-ssh_key1_renamed'
- first_ssh_key.key == "{{ test_key }}"
- first_ssh_key_updated.label == test_key_renamed
- first_ssh_key.key == test_key

- name: create second ssh_key for test
equinix.cloud.metal_ssh_key:
label: "{{ test_prefix }}-ssh_key2"
label: "{{ test_key_label2 }}"
key: "{{ test_key2 }}"
register: second_ssh_key

Expand All @@ -66,11 +72,11 @@
msg: "{{ ssh_keys_listed.resources }}"

- debug:
msg: 'ssh_keys_listed.resources | selectattr("label", "equalto", "{{ test_prefix }}-ssh_key2")'
msg: 'ssh_keys_listed.resources | selectattr("label", "equalto", test_key_label2)'

- assert:
that:
- 'ssh_keys_listed.resources | selectattr("label", "equalto", "{{ test_prefix }}-ssh_key2") | length == 1'
- 'ssh_keys_listed.resources | selectattr("label", "equalto", test_key_label2) | length == 1'

- name: list test ssh keys
set_fact:
Expand Down
8 changes: 2 additions & 6 deletions tests/integration/targets/metal_vlan/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@
name: "{{ test_prefix }}-project"
register: project

- assert:
that:
- project.name == '{{ test_prefix }}-project'

- name: create first vlan for test
equinix.cloud.metal_vlan:
project_id: "{{ project.id }}"
Expand All @@ -42,7 +38,7 @@

- assert:
that:
- first_vlan.vxlan == {{ test_vxlan }}
- first_vlan.vxlan == test_vxlan

- name: get vlan info
equinix.cloud.metal_vlan_info:
Expand All @@ -52,7 +48,7 @@
- assert:
that:
- "vlan_info_listed.resources | length == 1"
- vlan_info_listed.resources[0].id == "{{ first_vlan.id }}"
- vlan_info_listed.resources[0].id == first_vlan.id

- name: fetch existing vlan
equinix.cloud.metal_vlan:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/targets/metal_vrf/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
assert:
that:
- "vrf_list.resources|length == 1"
- "vrf_list.resources[0].id == '{{ test_vrf.id }}'"
- "vrf_list.resources[0].id == test_vrf.id"

- name: delete test VRF
equinix.cloud.metal_vrf:
Expand Down

0 comments on commit 8aae992

Please sign in to comment.