1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-09-02 07:16:37 +02:00

add some doc apis and tests

This commit is contained in:
Nikolay Kim
2018-09-12 13:34:53 -07:00
parent f66eec00e7
commit 62dbe1b001
6 changed files with 299 additions and 29 deletions

View File

@@ -167,3 +167,37 @@ where
}
}
}
#[cfg(test)]
mod tests {
use futures::future::{ok, FutureResult};
use futures::{Async, Future, Poll};
use service::{Service, ServiceExt};
#[derive(Clone)]
struct Srv;
impl Service for Srv {
type Request = ();
type Response = ();
type Error = ();
type Future = FutureResult<(), ()>;
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
Ok(Async::Ready(()))
}
fn call(&mut self, _: ()) -> Self::Future {
ok(())
}
}
#[test]
fn test_call() {
let mut srv =
Srv.apply(|req: &'static str, srv| srv.call(()).map(move |res| (req, res)));
let res = srv.call("srv").poll();
assert!(res.is_ok());
assert_eq!(res.unwrap(), Async::Ready(("srv", ())));
}
}