Fix deprecated warnings

This commit is contained in:
Nikolay Kim 2022-01-19 16:55:52 +06:00
parent 05f3231180
commit e5efdab4ed
5 changed files with 20 additions and 18 deletions

View file

@ -241,7 +241,7 @@ impl<T> SendError<T> {
#[cfg(test)]
mod tests {
use super::*;
use crate::{future::lazy, future::next, Stream};
use crate::{future::lazy, future::stream_recv, Stream};
use futures_sink::Sink;
#[ntex_macros::rt_test2]
@ -251,11 +251,11 @@ mod tests {
assert!(format!("{:?}", rx).contains("Receiver"));
tx.send("test").unwrap();
assert_eq!(next(&mut rx).await.unwrap(), "test");
assert_eq!(stream_recv(&mut rx).await.unwrap(), "test");
let tx2 = tx.clone();
tx2.send("test2").unwrap();
assert_eq!(next(&mut rx).await.unwrap(), "test2");
assert_eq!(stream_recv(&mut rx).await.unwrap(), "test2");
assert_eq!(
lazy(|cx| Pin::new(&mut rx).poll_next(cx)).await,
@ -270,7 +270,7 @@ mod tests {
let (tx, mut rx) = channel::<String>();
tx.close();
assert_eq!(next(&mut rx).await, None);
assert_eq!(stream_recv(&mut rx).await, None);
let (tx, _rx) = channel::<String>();
let weak_tx = tx.downgrade();
@ -303,8 +303,8 @@ mod tests {
assert!(Pin::new(&mut tx).poll_close(cx).is_ready());
})
.await;
assert_eq!(next(&mut rx).await.unwrap(), "test");
assert_eq!(next(&mut rx).await, None);
assert_eq!(stream_recv(&mut rx).await.unwrap(), "test");
assert_eq!(stream_recv(&mut rx).await, None);
}
#[ntex_macros::rt_test2]

View file

@ -169,7 +169,7 @@ mod tests {
use ntex_bytes::{ByteString, BytesMut};
use super::*;
use crate::{channel::mpsc, future::next, time::sleep, time::Millis};
use crate::{channel::mpsc, future::stream_recv, time::sleep, time::Millis};
#[ntex_macros::rt_test2]
async fn test_basic() {
@ -200,12 +200,12 @@ mod tests {
.unwrap();
tx.send(Ok::<_, ()>(buf.split().freeze())).unwrap();
let data = next(&mut rx).await.unwrap().unwrap();
let data = stream_recv(&mut rx).await.unwrap().unwrap();
assert_eq!(data, b"\x81\x04test".as_ref());
drop(tx);
sleep(Millis(10)).await;
assert!(next(&mut rx).await.is_none());
assert!(stream_recv(&mut rx).await.is_none());
assert_eq!(counter.get(), 1);
}

View file

@ -632,7 +632,7 @@ mod tests {
use crate::http::{body, Request, ResponseHead, StatusCode};
use crate::io::{self as nio, Base};
use crate::service::{boxed, fn_service, IntoService};
use crate::util::{lazy, next, Bytes, BytesMut};
use crate::util::{lazy, stream_recv, Bytes, BytesMut};
use crate::{codec::Decoder, testing::Io, time::sleep, time::Millis, time::Seconds};
const BUFFER_SIZE: usize = 32_768;
@ -797,7 +797,7 @@ mod tests {
spawn_h1(server, |mut req: Request| async move {
let mut p = req.take_payload();
while let Some(_) = next(&mut p).await {}
while let Some(_) = stream_recv(&mut p).await {}
Ok::<_, io::Error>(Response::Ok().finish())
});
@ -934,7 +934,7 @@ mod tests {
async move {
// read one chunk
let mut pl = req.take_payload();
let _ = next(&mut pl).await.unwrap().unwrap();
let _ = stream_recv(&mut pl).await.unwrap().unwrap();
m.store(true, Ordering::Relaxed);
// sleep
sleep(Millis(999_999_000)).await;

View file

@ -445,7 +445,7 @@ mod tests {
.await
.unwrap()
.into_inner();
let b = next(&mut s).await.unwrap().unwrap();
let b = stream_recv(&mut s).await.unwrap().unwrap();
assert_eq!(b, Bytes::from_static(b"hello=world"));
}

View file

@ -169,7 +169,9 @@ where
#[cfg(test)]
mod tests {
use super::*;
use crate::{channel::mpsc, util::next, util::poll_fn, util::send, util::ByteString};
use crate::{
channel::mpsc, util::poll_fn, util::send, util::stream_recv, util::ByteString,
};
#[crate::rt_test]
async fn test_decoder() {
@ -186,12 +188,12 @@ mod tests {
.unwrap();
tx.send(Ok::<_, ()>(buf.split().freeze())).unwrap();
let frame = next(&mut decoder).await.unwrap().unwrap();
let frame = stream_recv(&mut decoder).await.unwrap().unwrap();
match frame {
Frame::Text(data) => assert_eq!(data, b"test1"[..]),
_ => panic!(),
}
let frame = next(&mut decoder).await.unwrap().unwrap();
let frame = stream_recv(&mut decoder).await.unwrap().unwrap();
match frame {
Frame::Text(data) => assert_eq!(data, b"test2"[..]),
_ => panic!(),
@ -216,8 +218,8 @@ mod tests {
.await
.unwrap();
let data = next(&mut rx).await.unwrap().unwrap();
let data = stream_recv(&mut rx).await.unwrap().unwrap();
assert_eq!(data, b"\x81\x04test".as_ref());
assert!(next(&mut rx).await.is_none());
assert!(stream_recv(&mut rx).await.is_none());
}
}