hurl/integration/tests_ok/assert_json.hurl

97 lines
2.3 KiB
Plaintext
Raw Normal View History

2020-08-27 10:07:46 +03:00
GET http://localhost:8000/assert-json
[Options]
variable: one=1
variable: two=2
variable: three=3
variable: four=4
variable: five=5
2022-09-09 17:54:28 +03:00
variable: foo=abc
insecure: false
2022-11-11 16:25:00 +03:00
HTTP 200
[Captures]
count: jsonpath "$.count"
2020-08-27 10:07:46 +03:00
[Asserts]
jsonpath "$.count" == 5
jsonpath "$.count" == 5.0
jsonpath "$.count" == {{five}}
jsonpath "$.count" equals 5
2021-06-27 11:11:02 +03:00
jsonpath "$.count" != 4
jsonpath "$.count" != {{four}}
jsonpath "$.count" not equals 4
jsonpath "$.count" > 1
jsonpath "$.count" > {{one}}
jsonpath "$.count" > 1.0
jsonpath "$.count" greaterThan 1.0
jsonpath "$.success" == false
jsonpath "$.success" != null
2020-10-19 18:55:03 +03:00
jsonpath "$.success" exists
2020-11-28 20:37:31 +03:00
jsonpath "$.success" isBoolean
jsonpath "$.errors" count == 2
2020-11-28 20:37:31 +03:00
jsonpath "$.errors" isCollection
jsonpath "$.warnings" count == 0
2020-08-27 10:07:46 +03:00
jsonpath "$.toto" not exists
jsonpath "$.warnings" exists
jsonpath "$.warnings" exists
jsonpath "$.errors[0]" exists
2020-11-28 20:37:31 +03:00
jsonpath "$.errors[0]" isCollection
jsonpath "$.errors[0].id" == "error1"
jsonpath "$.errors[0]['id']" == "error1"
2021-02-15 12:12:00 +03:00
jsonpath "$.errors[*].id" includes "error1"
jsonpath "$.errors[?(@.id=='error1')].id" == "error1"
jsonpath "$.duration" == 1.5
jsonpath "$.duration" <= 2.0
2021-06-24 21:29:19 +03:00
jsonpath "$.duration" < 2
jsonpath "$.duration" < {{two}}
jsonpath "$.duration" lessThanOrEquals 2.0
jsonpath "$.duration" lessThan 2
2020-11-28 20:37:31 +03:00
jsonpath "$.duration" isFloat
jsonpath "$.duration" not isInteger
jsonpath "$.nullable" == null
2022-09-09 17:54:28 +03:00
jsonpath "$.tags[0]" == "test"
jsonpath "$.tags[0]" > "te"
jsonpath "$.tags[0]" < "testabc"
jsonpath "$.tags[0]" <= "test"
jsonpath "$.tags[0]" > "{{foo}}"
2023-01-17 20:37:31 +03:00
jsonpath "$.profile-id" == "123abc"
jsonpath "$['profile-id']" == "123abc"
2022-09-09 17:54:28 +03:00
2020-08-27 10:07:46 +03:00
{
"count": 5,
2020-08-27 10:07:46 +03:00
"success": false,
"errors": [{"id":"error1"},{"id":"error2"}],
"warnings": [],
"duration": 1.5,
"tags": ["test"],
2023-01-17 20:37:31 +03:00
"nullable": null,
"profile-id": "123abc"
2020-08-27 10:07:46 +03:00
}
GET http://localhost:8000/assert-json/index
2022-11-11 16:25:00 +03:00
HTTP 200
2020-08-27 10:07:46 +03:00
[Captures]
index: body
GET http://localhost:8000/assert-json
2022-11-11 16:25:00 +03:00
HTTP 200
2020-08-27 10:07:46 +03:00
[Asserts]
jsonpath "$.errors[{{index}}].id" == "error2"
2020-08-27 10:07:46 +03:00
jsonpath "$.tags" includes "test"
jsonpath "$.tags" not includes "prod"
jsonpath "$.tags" not includes null
GET http://localhost:8000/assert-json/list
2022-11-11 16:25:00 +03:00
HTTP 200
[Asserts]
jsonpath "$" count == 2
jsonpath "$.[0].name" == "Bob"
jsonpath "$[0].name" == "Bob"
GET http://localhost:8000/assert-json/filter
2022-11-11 16:25:00 +03:00
HTTP 200
[Asserts]
jsonpath "$.fruit[?(@.price.US==200)].name" equals "grape"