You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of 24fc843, it generates the following panic message:
thread 'basic_message' panicked at 'Matching failed', tests/error_message.rs:10:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
This is... less than ideal.
What could be done
What i'd love to see is a way to see is something like this:
thread 'basic_message' panicked at 'Failed to match the request output with the provided pattern:
Value returned: | Pattern expected:
|
| { | {
| first_name: "Grace", | first_name: _,
!! | last_name: "Hopper", | last_name: "Lovelace",
| } | }
', tests/error_message.rs:5:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Note that this output JSON-ifies the pattern. We could Rust-ify the value instead:
Value returned: | Pattern expected:
|
| User { | User {
| first_name: "Grace", | first_name: _,
!! | last_name: "Hopper", | last_name: "Lovelace",
| } | }
Implementation details
We can gather a set of "constraints" of the value returned by the server by using a custom Serializer, which could, from the previous example, return us the following constraints:
.first_name == "Grace"
.last_name == "Hopper"
We could gather the constraints from the pattern by defining a custom [Visitor], which could extract similar constraints from the pattern:
.first_name: _
.last_name: "Lovelace"
We could then visit each constraint from the pattern, get the corresponding constraint in the value-side, compare them (write the !! if required), then pretty-print both on each side.
The text was updated successfully, but these errors were encountered:
The following code snippet shows is an obvious incorrect call to
assert_body_matches
:As of 24fc843, it generates the following panic message:
This is... less than ideal.
What could be done
What i'd love to see is a way to see is something like this:
Note that this output JSON-ifies the pattern. We could Rust-ify the value instead:
Implementation details
We can gather a set of "constraints" of the value returned by the server by using a custom
Serializer
, which could, from the previous example, return us the following constraints:We could gather the constraints from the pattern by defining a custom [
Visitor
], which could extract similar constraints from the pattern:We could then visit each constraint from the pattern, get the corresponding constraint in the value-side, compare them (write the
!!
if required), then pretty-print both on each side.The text was updated successfully, but these errors were encountered: