Skip to content

Commit

Permalink
Add support for backtick strings in predicates values.
Browse files Browse the repository at this point in the history
We are now able to support this code:

```
GET http://foo.com
HTTP 200
[Asserts]
xpath "string(//title)" == `Bob says: "Hi"`
```
  • Loading branch information
jcamiel committed Oct 24, 2024
1 parent 9fd010b commit c80147d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion integration/hurl/tests_ok/assert_json.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jsonpath "$.failures" count == 1
jsonpath "$.failures" isCollection
jsonpath "$.warnings" count == 0
jsonpath "$.warnings" isEmpty
jsonpath "$.message" == "Bob says \"Hello\""
jsonpath "$.message" == `Bob says "Hello"`
jsonpath "$.toto" not exists
jsonpath "$.failures" exists
jsonpath "$.warnings" exists
Expand Down Expand Up @@ -62,7 +64,7 @@ jsonpath "$.profile-id" == "123abc"
jsonpath "$['profile-id']" == "123abc"
jsonpath "$.errors[0]" not isEmpty
jsonpath "$.empty" isEmpty
jsonpath "$.*" count == 11
jsonpath "$.*" count == 12
jsonpath "$.errors..*" count == 4
jsonpath "$..id" count == 3
jsonpath "$.dates[0]" isIsoDate
Expand All @@ -79,6 +81,7 @@ jsonpath "$.tags[0]" not isNumber
"errors": [{"id":"error1"},{"id":"error2"}],
"failures": [{"id":"failure1"}],
"warnings": [],
"message": "Bob says \"Hello\"",
"duration": 1.5,
"tags": ["test"],
"nullable": null,
Expand All @@ -101,6 +104,7 @@ GET http://localhost:8000/assert-json
HTTP 200
[Asserts]
jsonpath "$.errors[{{index}}].id" == "error2"
jsonpath "$.errors[{{index}}].id" == `error2`
jsonpath "$.tags" includes "test"
jsonpath "$.tags" not includes "prod"
jsonpath "$.tags" not includes null
Expand Down
1 change: 1 addition & 0 deletions integration/hurl/tests_ok/assert_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def assert_json():
"errors": [{"id":"error1"},{"id":"error2"}],
"failures": [{"id":"failure1"}],
"warnings": [],
"message": "Bob says \\"Hello\\"",
"duration": 1.5,
"tags": ["test"],
"nullable": null,
Expand Down
4 changes: 4 additions & 0 deletions packages/hurl_core/src/parser/predicate_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ pub fn predicate_value(reader: &mut Reader) -> ParseResult<PredicateValue> {
Ok(value) => Ok(PredicateValue::MultilineString(value)),
Err(e) => Err(e),
},
|p1| match backtick_template(p1) {
Ok(value) => Ok(PredicateValue::String(value)),
Err(e) => Err(e),
},
|p1| match regex(p1) {
Ok(value) => Ok(PredicateValue::Regex(value)),
Err(e) => Err(e),
Expand Down

0 comments on commit c80147d

Please sign in to comment.