1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-24 01:11:07 +01:00

update tests

This commit is contained in:
Nikolay Kim 2019-02-03 11:48:11 -08:00
parent 663ae53954
commit bcc466f6ab

View File

@ -242,10 +242,9 @@ mod tests {
#[test]
fn test_apply() {
let mut srv = Apply::new_fn(
|req: &'static str, srv| srv.call(()).map(move |res| (req, res)),
Srv,
);
let mut srv = Apply::new_fn(Srv, |req: &'static str, srv| {
srv.call(()).map(move |res| (req, res))
});
assert!(srv.poll_ready().is_ok());
let res = srv.call("srv").poll();
assert!(res.is_ok());
@ -268,19 +267,19 @@ mod tests {
}
}
// #[test]
// fn test_new_service_fn() {
// let new_srv = ApplyNewService::new_fn(
// || Ok(Srv),
// |req: &'static str, srv| srv.call(()).map(move |res| (req, res)),
// );
// if let Async::Ready(mut srv) = new_srv.new_service().poll().unwrap() {
// assert!(srv.poll_ready().is_ok());
// let res = srv.call("srv").poll();
// assert!(res.is_ok());
// assert_eq!(res.unwrap(), Async::Ready(("srv", ())));
// } else {
// panic!()
// }
// }
#[test]
fn test_new_service_fn() {
let new_srv = ApplyNewService::new_fn(
|| Ok::<_, ()>(Srv),
|req: &'static str, srv| srv.call(()).map(move |res| (req, res)),
);
if let Async::Ready(mut srv) = new_srv.new_service().poll().unwrap() {
assert!(srv.poll_ready().is_ok());
let res = srv.call("srv").poll();
assert!(res.is_ok());
assert_eq!(res.unwrap(), Async::Ready(("srv", ())));
} else {
panic!()
}
}
}