Skip to content

How can I assert equal BoxBody in actix 4.0 #2640

Answered by Overdash
Overdash asked this question in Q&A
Discussion options

You must be logged in to vote

For transparency:
Instead of comparing Bodies we can compare Bytes/Strings:

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

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@Overdash
Comment options

@Overdash
Comment options

@robjtede
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by Overdash
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants