Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refacto error_string in order to support diff messages #2617

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions integration/hurl/tests_failed/assert_newline.err
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ error: Assert body value
| ...
10 | <p>Hello</p>
| ^ actual value is <<p>Hello</p>

>
|
| >
|

4 changes: 2 additions & 2 deletions integration/hurl/tests_failed/assert_value_error.err
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ error: Assert failure
| ...
11 | jsonpath "$.line_terminator" == "\r\n"
| actual: string <
| >
|>
| expected: string <
| >
|>
|

error: Assert failure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
{
"line": 11,
"message": "Assert failure\n --> tests_failed/assert_value_error.hurl:11:0\n |\n | GET http://localhost:8000/error-assert-value\n | ...\n11 | jsonpath \"$.line_terminator\" == \"\\r\\n\"\n | actual: string <\n | >\n | expected: string <\n | >\n |",
"message": "Assert failure\n --> tests_failed/assert_value_error.hurl:11:0\n |\n | GET http://localhost:8000/error-assert-value\n | ...\n11 | jsonpath \"$.line_terminator\" == \"\\r\\n\"\n | actual: string <\n |>\n | expected: string <\n |>\n |",
"success": false
},
{
Expand Down
12 changes: 10 additions & 2 deletions packages/hurl/src/runner/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ impl hurl_core::error::Error for Error {
..
} => {
let additional = if *type_mismatch {
"\n>>> types between actual and expected are not consistent"
"\n >>> types between actual and expected are not consistent"
} else {
""
};
format!("actual: {actual}\nexpected: {expected}{additional}")
format!(" actual: {actual}\n expected: {expected}{additional}")
}
RunnerError::AssertHeaderValueError { actual } => {
format!("actual value is <{actual}>")
Expand Down Expand Up @@ -257,6 +257,14 @@ impl hurl_core::error::Error for Error {
}
}
}

fn show_source_line(&self) -> bool {
true
}

fn show_caret(&self) -> bool {
!matches!(&self.inner, RunnerError::AssertFailure { .. })
}
}

impl From<HttpError> for RunnerError {
Expand Down
Loading
Loading