Added test body_to_str_not_empty

Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
This commit is contained in:
Louis Vallat 2021-10-18 10:45:07 +02:00
parent cb9d1d50fd
commit a949f196c8
No known key found for this signature in database
GPG Key ID: 0C87282F76E61283

View File

@ -56,7 +56,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
} }
#[cfg(test)] #[cfg(test)]
mod tests { mod tests_main {
use hyper::{Body, Response}; use hyper::{Body, Response};
use crate::body_to_str; use crate::body_to_str;
@ -66,4 +66,13 @@ mod tests {
assert_eq!("", tokio_test::block_on(body_to_str(res))); assert_eq!("", tokio_test::block_on(body_to_str(res)));
} }
#[test]
fn body_to_str_not_empty() {
let res = Response::new(Body::from("demo"));
assert_eq!("demo", tokio_test::block_on(body_to_str(res)));
let res2 = Response::new(Body::from("hello world"));
assert_eq!("hello world", tokio_test::block_on(body_to_str(res2)));
}
} }