From ba58221310368236d563ac1d5f25c840f2671bcd Mon Sep 17 00:00:00 2001 From: yinho999 Date: Wed, 19 Apr 2023 22:08:00 +0100 Subject: [PATCH] Complete Unit Testing --- actix-http/src/body/channel.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/actix-http/src/body/channel.rs b/actix-http/src/body/channel.rs index e5cf605d6..5113316bd 100644 --- a/actix-http/src/body/channel.rs +++ b/actix-http/src/body/channel.rs @@ -16,7 +16,7 @@ use super::{BodySize, MessageBody}; /// ``` /// use actix_web::{HttpResponse, web}; /// use std::convert::Infallible; -/// use actix_web::body::channel; +/// use actix_http::body::channel; /// /// #[actix_rt::main] /// async fn main() { @@ -186,14 +186,12 @@ mod tests { #[actix_rt::test] async fn test_body_channel_error() { let (mut tx, rx) = channel::(); - let mut tx_cloned = tx.clone(); let rx = rx.boxed(); pin!(rx); assert_eq!(rx.size(), BodySize::Stream); tx.send(Bytes::from_static(b"test")).unwrap(); - tx_cloned.send(Bytes::from_static(b"test2")).unwrap(); let err = io::Error::new(io::ErrorKind::Other, "test"); @@ -214,20 +212,15 @@ mod tests { let (tx, rx) = channel::(); let rx = rx.boxed(); pin!(rx); - drop(tx); - - let err = poll_fn(|cx| rx.as_mut().poll_next(cx)).await.unwrap().err(); - assert!(err.is_some()); - assert_eq!(err.unwrap().to_string(), "channel closed"); + let received = poll_fn(|cx| rx.as_mut().poll_next(cx)).await; + assert!(received.is_none()); } #[actix_rt::test] async fn test_dropped_receiver() { let (mut tx, rx) = channel::(); let rx = rx.boxed(); - pin!(rx); - drop(rx); let err = tx.send(Bytes::from_static(b"test")).unwrap_err();