Closed CuriousCorrelation closed 2 years ago
Message on failing a test with common::test_body(left, right) fn look like this:
common::test_body(left, right)
fn
---- proc_macro::different_fn_types::test_str stdout ---- thread '...' panicked at 'assertion failed: `(left == right)` left: `"Hi!"`, right: `"Hello!"`', tests/file... note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
which corrosponds to
common::test_body("Hello!", "Hi!").await;
The lhs/rhs mismatch between compiler's message and the function params is due to the underlying assert_eq! swap of expected and received args
assert_eq!
expected
received
pub async fn test_body(resp: ServiceResponse, expected_body: &str) { │ let body = test::read_body(resp).await; │ assert_eq!(expected_body, String::from_utf8(body.to_vec()).unwrap()); }
Swapping lhs and rhs
lhs
rhs
pub async fn test_body(resp: ServiceResponse, expected_body: &str) { │ let body = test::read_body(resp).await; │ assert_eq!(String::from_utf8(body.to_vec()).unwrap(), expected_body); }
fixes this issue.
This follows The Rust Book convention of
assert_eq!(actual, expected);
I have a PR ready to go if this feels like a worthwhile issue and doesn't violate library wide chosen convention.
Go ahead 🙂
Message on failing a test with
common::test_body(left, right)
fn
look like this:which corrosponds to
The lhs/rhs mismatch between compiler's message and the function params is due to the underlying
assert_eq!
swap ofexpected
andreceived
argsSwapping
lhs
andrhs
fixes this issue.
This follows The Rust Book convention of
I have a PR ready to go if this feels like a worthwhile issue and doesn't violate library wide chosen convention.