1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-06-26 22:07:42 +02:00

add test and main macros

This commit is contained in:
Nikolay Kim
2019-11-25 21:49:11 +06:00
parent 1fddd1e75b
commit 4ceac79f2c
25 changed files with 265 additions and 267 deletions

View File

@ -24,8 +24,7 @@ path = "src/lib.rs"
[dependencies]
futures = "0.3.1"
pin-project = "0.4.5"
pin-project = "0.4.6"
[dev-dependencies]
tokio = "0.2.0-alpha.6"
# actix-rt = "1.0.0-alpha.1"
actix-rt = "1.0.0-alpha.1"

View File

@ -292,7 +292,7 @@ mod tests {
}
}
#[tokio::test]
#[actix_rt::test]
async fn test_poll_ready() {
let cnt = Rc::new(Cell::new(0));
let mut srv = pipeline(Srv1(cnt.clone())).and_then(Srv2(cnt.clone()));
@ -301,7 +301,7 @@ mod tests {
assert_eq!(cnt.get(), 2);
}
#[tokio::test]
#[actix_rt::test]
async fn test_call() {
let cnt = Rc::new(Cell::new(0));
let mut srv = pipeline(Srv1(cnt.clone())).and_then(Srv2(cnt));
@ -310,7 +310,7 @@ mod tests {
assert_eq!(res.unwrap(), (("srv1", "srv2")));
}
#[tokio::test]
#[actix_rt::test]
async fn test_new_service() {
let cnt = Rc::new(Cell::new(0));
let cnt2 = cnt.clone();

View File

@ -196,7 +196,7 @@ mod tests {
}
}
#[tokio::test]
#[actix_rt::test]
async fn test_call() {
let mut srv = pipeline(apply_fn(Srv, |req: &'static str, srv| {
let fut = srv.call(());
@ -213,7 +213,7 @@ mod tests {
assert_eq!(res.unwrap(), (("srv", ())));
}
#[tokio::test]
#[actix_rt::test]
async fn test_new_service() {
let new_srv = pipeline_factory(apply_fn_factory(
|| ok::<_, ()>(Srv),

View File

@ -219,14 +219,14 @@ mod tests {
}
}
#[tokio::test]
#[actix_rt::test]
async fn test_poll_ready() {
let mut srv = Srv.map(|_| "ok");
let res = lazy(|cx| srv.poll_ready(cx)).await;
assert_eq!(res, Poll::Ready(Ok(())));
}
#[tokio::test]
#[actix_rt::test]
async fn test_call() {
let mut srv = Srv.map(|_| "ok");
let res = srv.call(()).await;
@ -234,7 +234,7 @@ mod tests {
assert_eq!(res.unwrap(), "ok");
}
#[tokio::test]
#[actix_rt::test]
async fn test_new_service() {
let new_srv = (|| ok::<_, ()>(Srv)).into_factory().map(|_| "ok");
let mut srv = new_srv.new_service(&()).await.unwrap();

View File

@ -221,14 +221,14 @@ mod tests {
}
}
#[tokio::test]
#[actix_rt::test]
async fn test_poll_ready() {
let mut srv = Srv.map_err(|_| "error");
let res = lazy(|cx| srv.poll_ready(cx)).await;
assert_eq!(res, Poll::Ready(Err("error")));
}
#[tokio::test]
#[actix_rt::test]
async fn test_call() {
let mut srv = Srv.map_err(|_| "error");
let res = srv.call(()).await;
@ -236,7 +236,7 @@ mod tests {
assert_eq!(res.err().unwrap(), "error");
}
#[tokio::test]
#[actix_rt::test]
async fn test_new_service() {
let new_srv = (|| ok::<_, ()>(Srv)).into_factory().map_err(|_| "error");
let mut srv = new_srv.new_service(&()).await.unwrap();

View File

@ -307,7 +307,7 @@ mod tests {
}
}
#[tokio::test]
#[actix_rt::test]
async fn test_poll_ready() {
let cnt = Rc::new(Cell::new(0));
let mut srv = pipeline(Srv1(cnt.clone())).then(Srv2(cnt.clone()));
@ -316,7 +316,7 @@ mod tests {
assert_eq!(cnt.get(), 2);
}
#[tokio::test]
#[actix_rt::test]
async fn test_call() {
let cnt = Rc::new(Cell::new(0));
let mut srv = pipeline(Srv1(cnt.clone())).then(Srv2(cnt));
@ -330,7 +330,7 @@ mod tests {
assert_eq!(res.unwrap(), (("srv2", "err")));
}
#[tokio::test]
#[actix_rt::test]
async fn test_factory() {
let cnt = Rc::new(Cell::new(0));
let cnt2 = cnt.clone();