clippy warns

This commit is contained in:
Nikolay Kim 2020-04-17 00:24:31 +06:00
parent 63cde53f22
commit 1dee624ccd
5 changed files with 22 additions and 23 deletions

View file

@ -521,6 +521,7 @@ mod tests {
} }
#[test] #[test]
#[allow(clippy::let_unit_value, clippy::unit_cmp)]
fn test_request_extract() { fn test_request_extract() {
let mut path = Path::new("/name/user1/"); let mut path = Path::new("/name/user1/");
path.segments = vec![ path.segments = vec![

View file

@ -327,7 +327,7 @@ mod tests {
let srv = pipeline(Srv1(cnt.clone())).and_then(Srv2(cnt)); let srv = pipeline(Srv1(cnt.clone())).and_then(Srv2(cnt));
let res = srv.call("srv1").await; let res = srv.call("srv1").await;
assert!(res.is_ok()); assert!(res.is_ok());
assert_eq!(res.unwrap(), (("srv1", "srv2"))); assert_eq!(res.unwrap(), ("srv1", "srv2"));
} }
#[ntex_rt::test] #[ntex_rt::test]

View file

@ -305,17 +305,16 @@ mod tests {
Poll::Ready(Ok(())) Poll::Ready(Ok(()))
} }
fn call(&self, req: Self::Request) -> Self::Future { fn call(&self, _: Self::Request) -> Self::Future {
ok(req) ok(())
} }
} }
#[ntex_rt::test] #[ntex_rt::test]
async fn test_service() { async fn test_service() {
let srv = pipeline(|r: &'static str| ok(r)) let srv = pipeline(ok).and_then_apply_fn(Srv, |req: &'static str, s| {
.and_then_apply_fn(Srv, |req: &'static str, s| { s.call(()).map_ok(move |res| (req, res))
s.call(()).map_ok(move |res| (req, res)) });
});
let res = lazy(|cx| srv.poll_ready(cx)).await; let res = lazy(|cx| srv.poll_ready(cx)).await;
assert_eq!(res, Poll::Ready(Ok(()))); assert_eq!(res, Poll::Ready(Ok(())));
@ -326,12 +325,11 @@ mod tests {
#[ntex_rt::test] #[ntex_rt::test]
async fn test_service_factory() { async fn test_service_factory() {
let new_srv = let new_srv = pipeline_factory(|| ok::<_, ()>(fn_service(ok)))
pipeline_factory(|| ok::<_, ()>(fn_service(|r: &'static str| ok(r)))) .and_then_apply_fn(
.and_then_apply_fn( || ok(Srv),
|| ok(Srv), |req: &'static str, s| s.call(()).map_ok(move |res| (req, res)),
|req: &'static str, s| s.call(()).map_ok(move |res| (req, res)), );
);
let srv = new_srv.new_service(()).await.unwrap(); let srv = new_srv.new_service(()).await.unwrap();
let res = lazy(|cx| srv.poll_ready(cx)).await; let res = lazy(|cx| srv.poll_ready(cx)).await;
assert_eq!(res, Poll::Ready(Ok(()))); assert_eq!(res, Poll::Ready(Ok(())));

View file

@ -243,8 +243,8 @@ mod tests {
let srv = pipeline(apply_fn(Srv, |req: &'static str, srv| { let srv = pipeline(apply_fn(Srv, |req: &'static str, srv| {
let fut = srv.call(()); let fut = srv.call(());
async move { async move {
let res = fut.await.unwrap(); fut.await.unwrap();
Ok((req, res)) Ok((req, ()))
} }
})); }));
@ -252,7 +252,7 @@ mod tests {
let res = srv.call("srv").await; let res = srv.call("srv").await;
assert!(res.is_ok()); assert!(res.is_ok());
assert_eq!(res.unwrap(), (("srv", ()))); assert_eq!(res.unwrap(), ("srv", ()));
} }
#[ntex_rt::test] #[ntex_rt::test]
@ -262,8 +262,8 @@ mod tests {
|req: &'static str, srv| { |req: &'static str, srv| {
let fut = srv.call(()); let fut = srv.call(());
async move { async move {
let res = fut.await.unwrap(); fut.await.unwrap();
Ok((req, res)) Ok((req, ()))
} }
}, },
)); ));
@ -274,6 +274,6 @@ mod tests {
let res = srv.call("srv").await; let res = srv.call("srv").await;
assert!(res.is_ok()); assert!(res.is_ok());
assert_eq!(res.unwrap(), (("srv", ()))); assert_eq!(res.unwrap(), ("srv", ()));
} }
} }

View file

@ -321,11 +321,11 @@ mod tests {
let res = srv.call(Ok("srv1")).await; let res = srv.call(Ok("srv1")).await;
assert!(res.is_ok()); assert!(res.is_ok());
assert_eq!(res.unwrap(), (("srv1", "ok"))); assert_eq!(res.unwrap(), ("srv1", "ok"));
let res = srv.call(Err("srv")).await; let res = srv.call(Err("srv")).await;
assert!(res.is_ok()); assert!(res.is_ok());
assert_eq!(res.unwrap(), (("srv2", "err"))); assert_eq!(res.unwrap(), ("srv2", "err"));
} }
#[ntex_rt::test] #[ntex_rt::test]
@ -337,10 +337,10 @@ mod tests {
let srv = factory.new_service(&()).await.unwrap(); let srv = factory.new_service(&()).await.unwrap();
let res = srv.call(Ok("srv1")).await; let res = srv.call(Ok("srv1")).await;
assert!(res.is_ok()); assert!(res.is_ok());
assert_eq!(res.unwrap(), (("srv1", "ok"))); assert_eq!(res.unwrap(), ("srv1", "ok"));
let res = srv.call(Err("srv")).await; let res = srv.call(Err("srv")).await;
assert!(res.is_ok()); assert!(res.is_ok());
assert_eq!(res.unwrap(), (("srv2", "err"))); assert_eq!(res.unwrap(), ("srv2", "err"));
} }
} }