mirror of
https://github.com/ntex-rs/ntex.git
synced 2025-04-04 21:37:58 +03:00
Improve tests (#548)
This commit is contained in:
parent
30928d019c
commit
f6fe9c3e10
1 changed files with 5 additions and 6 deletions
|
@ -446,13 +446,12 @@ async fn test_h2_client_drop() -> io::Result<()> {
|
||||||
let count = count2.clone();
|
let count = count2.clone();
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.h2(move |req: Request| {
|
.h2(move |req: Request| {
|
||||||
let tx = tx.clone();
|
let st = SetOnDrop(count.clone(), tx.clone());
|
||||||
let count = count.clone();
|
|
||||||
async move {
|
async move {
|
||||||
let _st = SetOnDrop(count, tx);
|
|
||||||
assert!(req.peer_addr().is_some());
|
assert!(req.peer_addr().is_some());
|
||||||
assert_eq!(req.version(), Version::HTTP_2);
|
assert_eq!(req.version(), Version::HTTP_2);
|
||||||
sleep(Seconds(100)).await;
|
sleep(Seconds(30)).await;
|
||||||
|
drop(st);
|
||||||
Ok::<_, io::Error>(Response::Ok().finish())
|
Ok::<_, io::Error>(Response::Ok().finish())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -460,9 +459,9 @@ async fn test_h2_client_drop() -> io::Result<()> {
|
||||||
.map_err(|_| ())
|
.map_err(|_| ())
|
||||||
});
|
});
|
||||||
|
|
||||||
let result = timeout(Millis(250), srv.srequest(Method::GET, "/").send()).await;
|
let result = timeout(Millis(150), srv.srequest(Method::GET, "/").send()).await;
|
||||||
assert!(result.is_err());
|
assert!(result.is_err());
|
||||||
let _ = rx.await;
|
let _ = timeout(Millis(1500), rx).await;
|
||||||
assert_eq!(count.load(Ordering::Relaxed), 1);
|
assert_eq!(count.load(Ordering::Relaxed), 1);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue