Created
September 27, 2018 19:13
-
-
Save dmerejkowsky/36a5fe4e2b8aaf0ef6b60ab2cb704383 to your computer and use it in GitHub Desktop.
actix unit test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn body_contains(response: &HttpResponse, fragment: &str) -> bool { | |
// TODO: this looks really complicated. I must be missing something here :/ | |
let body = response.body(); | |
if let Binary(b) = body { | |
if let Bytes(bytes) = b { | |
let text = str::from_utf8(&bytes).unwrap(); | |
return text.contains(fragment); | |
} | |
} | |
panic!("Expecting a binary response"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment