Skip to content

Commit 1af054d

Browse files
committed
Compare strings against strings
Ansible saves vars as strings, even if the return from a filter was an integer
1 parent 19bac28 commit 1af054d

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

tests/integration/targets/v3.5/tasks/netbox_lookup.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
##
77
- name: "NETBOX_LOOKUP 1: Lookup returns exactly two sites"
88
assert:
9-
that: query_result == 3
9+
that: query_result == "3"
1010
vars:
1111
query_result: "{{ query('netbox.netbox.nb_lookup', 'sites', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567')|count }}"
1212

1313
- name: "NETBOX_LOOKUP 2: Query doesn't return Wibble (sanity check json_query)"
1414
assert:
15-
that: query_result == 0
15+
that: query_result == "0"
1616
vars:
1717
query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567')|community.general.json_query('[?value.display==`Wibble`]')|count}}"
1818

1919
- name: "NETBOX_LOOKUP 3: Device query returns exactly one TestDeviceR1"
2020
assert:
21-
that: query_result == 1
21+
that: query_result == "1"
2222
vars:
2323
query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567')|community.general.json_query('[?value.display==`TestDeviceR1`]')|count }}"
2424

@@ -58,13 +58,13 @@
5858

5959
- name: "NETBOX_LOOKUP 7: Device query returns exactly the L2 device"
6060
assert:
61-
that: query_result == 1
61+
that: query_result == "1"
6262
vars:
6363
query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_filter='role=core-switch tag=lookup', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567')|community.general.json_query('[?value.display==`L2`]')|count }}"
6464

6565
- name: "NETBOX_LOOKUP 8: Device query specifying raw data returns payload without key/value dict"
6666
assert:
67-
that: query_result == 1
67+
that: query_result == "1"
6868
vars:
6969
query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_filter='role=core-switch tag=lookup', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567', raw_data=True)|community.general.json_query('[?display==`L2`]')|count }}"
7070

tests/integration/targets/v3.6/tasks/netbox_lookup.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
##
77
- name: "NETBOX_LOOKUP 1: Lookup returns exactly two sites"
88
assert:
9-
that: query_result == 3
9+
that: query_result == "3"
1010
vars:
1111
query_result: "{{ query('netbox.netbox.nb_lookup', 'sites', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567')|count }}"
1212

1313
- name: "NETBOX_LOOKUP 2: Query doesn't return Wibble (sanity check json_query)"
1414
assert:
15-
that: query_result == 0
15+
that: query_result == "0"
1616
vars:
1717
query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567')|community.general.json_query('[?value.display==`Wibble`]')|count}}"
1818

1919
- name: "NETBOX_LOOKUP 3: Device query returns exactly one TestDeviceR1"
2020
assert:
21-
that: query_result == 1
21+
that: query_result == "1"
2222
vars:
2323
query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567')|community.general.json_query('[?value.display==`TestDeviceR1`]')|count }}"
2424

@@ -58,13 +58,13 @@
5858

5959
- name: "NETBOX_LOOKUP 7: Device query returns exactly the L2 device"
6060
assert:
61-
that: query_result == 1
61+
that: query_result == "1"
6262
vars:
6363
query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_filter='role=core-switch tag=lookup', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567')|community.general.json_query('[?value.display==`L2`]')|count }}"
6464

6565
- name: "NETBOX_LOOKUP 8: Device query specifying raw data returns payload without key/value dict"
6666
assert:
67-
that: query_result == 1
67+
that: query_result == "1"
6868
vars:
6969
query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_filter='role=core-switch tag=lookup', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567', raw_data=True)|community.general.json_query('[?display==`L2`]')|count }}"
7070

tests/integration/targets/v3.7/tasks/netbox_lookup.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
##
77
- name: "NETBOX_LOOKUP 1: Lookup returns exactly two sites"
88
assert:
9-
that: query_result == 3
9+
that: query_result == "3"
1010
vars:
1111
query_result: "{{ query('netbox.netbox.nb_lookup', 'sites', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567')|count }}"
1212

1313
- name: "NETBOX_LOOKUP 2: Query doesn't return Wibble (sanity check json_query)"
1414
assert:
15-
that: query_result == 0
15+
that: query_result == "0"
1616
vars:
1717
query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567')|community.general.json_query('[?value.display==`Wibble`]')|count}}"
1818

1919
- name: "NETBOX_LOOKUP 3: Device query returns exactly one TestDeviceR1"
2020
assert:
21-
that: query_result == 1
21+
that: query_result == "1"
2222
vars:
2323
query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567')|community.general.json_query('[?value.display==`TestDeviceR1`]')|count }}"
2424

@@ -58,13 +58,13 @@
5858

5959
- name: "NETBOX_LOOKUP 7: Device query returns exactly the L2 device"
6060
assert:
61-
that: query_result == 1
61+
that: query_result == "1"
6262
vars:
6363
query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_filter='role=core-switch tag=lookup', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567')|community.general.json_query('[?value.display==`L2`]')|count }}"
6464

6565
- name: "NETBOX_LOOKUP 8: Device query specifying raw data returns payload without key/value dict"
6666
assert:
67-
that: query_result == 1
67+
that: query_result == "1"
6868
vars:
6969
query_result: "{{ query('netbox.netbox.nb_lookup', 'devices', api_filter='role=core-switch tag=lookup', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567', raw_data=True)|community.general.json_query('[?display==`L2`]')|count }}"
7070

0 commit comments

Comments
 (0)