mirror of
https://github.com/fafhrd91/actix-net
synced 2025-01-19 03:44:40 +01:00
better InOrder test
This commit is contained in:
parent
4305cdba2c
commit
33fd6adc11
@ -1,10 +1,10 @@
|
|||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::convert::Infallible;
|
use std::convert::Infallible;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::rc::Rc;
|
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
|
use std::rc::Rc;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
|
||||||
use actix_service::{IntoService, Service, Transform};
|
use actix_service::{IntoService, Service, Transform};
|
||||||
@ -211,7 +211,7 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use actix_service::Service;
|
use actix_service::Service;
|
||||||
use futures::channel::oneshot;
|
use futures::channel::oneshot;
|
||||||
use futures::future::{lazy, FutureExt, LocalBoxFuture};
|
use futures::future::{lazy, poll_fn, FutureExt, LocalBoxFuture};
|
||||||
|
|
||||||
struct Srv;
|
struct Srv;
|
||||||
|
|
||||||
@ -245,15 +245,18 @@ mod tests {
|
|||||||
let _ = actix_rt::System::new("test").block_on(async {
|
let _ = actix_rt::System::new("test").block_on(async {
|
||||||
let mut srv = InOrderService::new(Srv);
|
let mut srv = InOrderService::new(Srv);
|
||||||
|
|
||||||
|
let _ = lazy(|cx| srv.poll_ready(cx)).await;
|
||||||
let res1 = srv.call(rx1);
|
let res1 = srv.call(rx1);
|
||||||
let res2 = srv.call(rx2);
|
let res2 = srv.call(rx2);
|
||||||
let res3 = srv.call(rx3);
|
let res3 = srv.call(rx3);
|
||||||
|
|
||||||
let _ = lazy(|cx| srv.poll_ready(cx)).await;
|
actix_rt::spawn(async move {
|
||||||
|
let _ = poll_fn(|cx| {
|
||||||
// dispatcher do this
|
let _ = srv.poll_ready(cx);
|
||||||
actix_rt::time::delay_for(Duration::from_millis(100)).await;
|
Poll::<()>::Pending
|
||||||
let _ = lazy(|cx| srv.poll_ready(cx)).await;
|
})
|
||||||
|
.await;
|
||||||
|
});
|
||||||
|
|
||||||
assert_eq!(res1.await.unwrap(), 1);
|
assert_eq!(res1.await.unwrap(), 1);
|
||||||
assert_eq!(res2.await.unwrap(), 2);
|
assert_eq!(res2.await.unwrap(), 2);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user