-
I was using let body = err_http_response().into_body();
let expected_resp = APIError {
code: StatusCode::BAD_REQUEST.as_u16(),
message: "Validation check failed".to_string(),
errors: Some(field_errors)
};
assert_eq!(body, Body::new(json!(expected_resp).to_string())) I realised my tests now fail after upgrading to |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
let result: serde_json::Value = test::read_body_json(res).await;
assert_eq!(result, json!(expected); |
Beta Was this translation helpful? Give feedback.
-
For transparency: Byte comp: assert_eq!(&body.try_into_bytes().unwrap()[..], json!(expected).to_string().as_bytes()) String comp: assert_eq!(std::str::from_utf8(&body.try_into_bytes().unwrap()[..]).unwrap(), json!(expected).to_string()) It's extremely ugly and unelegant. But it works lol |
Beta Was this translation helpful? Give feedback.
-
Compare serde values:
|
Beta Was this translation helpful? Give feedback.
For transparency:
Instead of comparing Bodies we can compare Bytes/Strings:
Byte comp:
String comp:
It's extremely ugly and unelegant. But it works lol