Update integration test on toFloat filter.
This commit is contained in:
parent
c070c739e6
commit
1e105fd0dd
|
|
@ -359,11 +359,38 @@ error: Filter error
|
|||
|
|
||||
|
||||
error: Filter error
|
||||
--> tests_failed/filter.hurl:49:24
|
||||
--> tests_failed/filter.hurl:44:22
|
||||
|
|
||||
| GET http://localhost:8000/error-filter
|
||||
| ...
|
||||
49 | foo: jsonpath "$.list" jsonpath "$.foo"
|
||||
44 | jsonpath "$.big_int" toFloat == 10000000000000000365.0
|
||||
| ^^^^^^^ invalid filter input: integer <10000000000000000365> is too big to be cast as a float
|
||||
|
|
||||
|
||||
error: Filter error
|
||||
--> tests_failed/filter.hurl:45:17
|
||||
|
|
||||
| GET http://localhost:8000/error-filter
|
||||
| ...
|
||||
45 | jsonpath "$.id" toFloat == 1.23
|
||||
| ^^^^^^^ invalid filter input: string <123x>
|
||||
|
|
||||
|
||||
error: Filter error
|
||||
--> tests_failed/filter.hurl:46:31
|
||||
|
|
||||
| GET http://localhost:8000/error-filter
|
||||
| ...
|
||||
46 | jsonpath "$.date" toDate "%+" toFloat == 3.14
|
||||
| ^^^^^^^ invalid filter input: date <2023-01-23 18:25:43.511 UTC>
|
||||
|
|
||||
|
||||
error: Filter error
|
||||
--> tests_failed/filter.hurl:52:24
|
||||
|
|
||||
| GET http://localhost:8000/error-filter
|
||||
| ...
|
||||
52 | foo: jsonpath "$.list" jsonpath "$.foo"
|
||||
| ^^^^^^^^^^^^^^^^ a filter didn't return any result
|
||||
|
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,9 @@ jsonpath "$.list" toString == "[]"
|
|||
jsonpath "$.invalid_xml" xpath "normalize-space(//book)" == "foo"
|
||||
jsonpath "$.id" urlQueryParam "q" == "something"
|
||||
jsonpath "$.date" toDate "%Y-%m-%dT%H:%M:%S%.fZ" format "%👻" == "Monday"
|
||||
jsonpath "$.big_int" toFloat == 10000000000000000365.0
|
||||
jsonpath "$.id" toFloat == 1.23
|
||||
jsonpath "$.date" toDate "%+" toFloat == 3.14
|
||||
|
||||
|
||||
GET http://localhost:8000/error-filter
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ def error_filter():
|
|||
"empty_list": [],
|
||||
"number": 42,
|
||||
"invalid_xml": "<?xml version=\\"1.0\\"",
|
||||
"date": "2023-01-23T18:25:43.511Z"
|
||||
"date": "2023-01-23T18:25:43.511Z",
|
||||
"big_int": 10000000000000000365
|
||||
}
|
||||
""",
|
||||
mimetype="application/json",
|
||||
|
|
|
|||
|
|
@ -35,6 +35,13 @@ pub fn eval_to_float(
|
|||
Err(RunnerError::new(source_info, kind, assert))
|
||||
}
|
||||
},
|
||||
Value::Number(Number::BigInteger(_)) => {
|
||||
let kind = RunnerErrorKind::FilterInvalidInput(format!(
|
||||
"{} is too big to be cast as a float",
|
||||
value.repr()
|
||||
));
|
||||
Err(RunnerError::new(source_info, kind, assert))
|
||||
}
|
||||
v => {
|
||||
let kind = RunnerErrorKind::FilterInvalidInput(v.repr());
|
||||
Err(RunnerError::new(source_info, kind, assert))
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ pub fn eval_to_string(
|
|||
assert: bool,
|
||||
) -> Result<Option<Value>, RunnerError> {
|
||||
match value.render() {
|
||||
Some(value) => Ok(Some(Value::String(value))),
|
||||
None => {
|
||||
let kind = RunnerErrorKind::FilterInvalidInput(format!(
|
||||
"{} can not be converted to a string",
|
||||
|
|
@ -35,7 +36,6 @@ pub fn eval_to_string(
|
|||
));
|
||||
Err(RunnerError::new(source_info, kind, assert))
|
||||
}
|
||||
Some(value) => Ok(Some(Value::String(value))),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue