mirror of
https://github.com/ntex-rs/ntex.git
synced 2025-04-03 21:07:39 +03:00
update tests
This commit is contained in:
parent
284cc4caf0
commit
9638f2bf58
10 changed files with 30 additions and 30 deletions
|
@ -288,7 +288,7 @@ mod tests {
|
|||
}
|
||||
|
||||
fn call(&self, req: &'static str) -> Self::Future {
|
||||
Ready::ok(req)
|
||||
Ready::Ok(req)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -307,7 +307,7 @@ mod tests {
|
|||
}
|
||||
|
||||
fn call(&self, req: &'static str) -> Self::Future {
|
||||
Ready::ok((req, "srv2"))
|
||||
Ready::Ok((req, "srv2"))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -339,9 +339,9 @@ mod tests {
|
|||
let cnt = Rc::new(Cell::new(0));
|
||||
let cnt2 = cnt.clone();
|
||||
let new_srv = pipeline_factory(fn_factory(move || {
|
||||
Ready::result(Ok::<_, ()>(Srv1(cnt2.clone())))
|
||||
Ready::from(Ok::<_, ()>(Srv1(cnt2.clone())))
|
||||
}))
|
||||
.and_then(move || Ready::result(Ok(Srv2(cnt.clone()))))
|
||||
.and_then(move || Ready::from(Ok(Srv2(cnt.clone()))))
|
||||
.clone();
|
||||
|
||||
let srv = new_srv.new_service(()).await.unwrap();
|
||||
|
|
|
@ -308,13 +308,13 @@ mod tests {
|
|||
}
|
||||
|
||||
fn call(&self, _: Self::Request) -> Self::Future {
|
||||
Ready::ok(())
|
||||
Ready::Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[ntex::test]
|
||||
async fn test_service() {
|
||||
let srv = pipeline(Ready::<_, ()>::ok)
|
||||
let srv = pipeline(Ready::<_, ()>::Ok)
|
||||
.and_then_apply_fn(Srv, |req: &'static str, s| {
|
||||
let f = s.call(());
|
||||
async move { f.await.map(move |res| (req, res)) }
|
||||
|
@ -334,9 +334,9 @@ mod tests {
|
|||
#[ntex::test]
|
||||
async fn test_service_factory() {
|
||||
let new_srv =
|
||||
pipeline_factory(|| Ready::<_, ()>::ok(fn_service(Ready::<_, ()>::ok)))
|
||||
pipeline_factory(|| Ready::<_, ()>::Ok(fn_service(Ready::<_, ()>::Ok)))
|
||||
.and_then_apply_fn(
|
||||
|| Ready::ok(Srv),
|
||||
|| Ready::Ok(Srv),
|
||||
|req: &'static str, s| {
|
||||
let f = s.call(());
|
||||
async move { f.await.map(move |res| (req, res)) }
|
||||
|
|
|
@ -232,7 +232,7 @@ mod tests {
|
|||
}
|
||||
|
||||
fn call(&self, _: ()) -> Self::Future {
|
||||
Ready::ok(())
|
||||
Ready::Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ mod tests {
|
|||
async fn test_new_service() {
|
||||
let new_srv = pipeline_factory(
|
||||
apply_fn_factory(
|
||||
|| Ready::<_, ()>::ok(Srv),
|
||||
|| Ready::<_, ()>::Ok(Srv),
|
||||
|req: &'static str, srv| {
|
||||
let fut = srv.call(());
|
||||
async move {
|
||||
|
|
|
@ -238,7 +238,7 @@ mod tests {
|
|||
let item2 = item.clone();
|
||||
|
||||
let srv = apply_cfg(
|
||||
fn_service(move |item: usize| Ready::<_, ()>::ok(item + 1)),
|
||||
fn_service(move |item: usize| Ready::<_, ()>::Ok(item + 1)),
|
||||
move |_: (), srv| {
|
||||
let id = item2.get();
|
||||
let fut = srv.call(id);
|
||||
|
@ -246,7 +246,7 @@ mod tests {
|
|||
|
||||
async move {
|
||||
item.set(fut.await.unwrap());
|
||||
Ok::<_, ()>(fn_service(|id: usize| Ready::<_, ()>::ok(id * 2)))
|
||||
Ok::<_, ()>(fn_service(|id: usize| Ready::<_, ()>::Ok(id * 2)))
|
||||
}
|
||||
},
|
||||
)
|
||||
|
@ -265,7 +265,7 @@ mod tests {
|
|||
let item2 = item.clone();
|
||||
|
||||
let srv = apply_cfg_factory(
|
||||
fn_service(move |item: usize| Ready::<_, ()>::ok(item + 1)),
|
||||
fn_service(move |item: usize| Ready::<_, ()>::Ok(item + 1)),
|
||||
move |_: (), srv| {
|
||||
let id = item2.get();
|
||||
let fut = srv.call(id);
|
||||
|
@ -273,7 +273,7 @@ mod tests {
|
|||
|
||||
async move {
|
||||
item.set(fut.await.unwrap());
|
||||
Ok::<_, ()>(fn_service(|id: usize| Ready::<_, ()>::ok(id * 2)))
|
||||
Ok::<_, ()>(fn_service(|id: usize| Ready::<_, ()>::Ok(id * 2)))
|
||||
}
|
||||
},
|
||||
)
|
||||
|
|
|
@ -86,7 +86,7 @@ mod tests {
|
|||
}
|
||||
|
||||
fn call(&self, i: usize) -> Self::Future {
|
||||
Ready::ok(i * 2)
|
||||
Ready::Ok(i * 2)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -223,7 +223,7 @@ mod tests {
|
|||
}
|
||||
|
||||
fn call(&self, _: ()) -> Self::Future {
|
||||
Ready::ok(())
|
||||
Ready::Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -314,7 +314,7 @@ mod tests {
|
|||
let item = Rc::new(Cell::new(1usize));
|
||||
|
||||
let factory = map_config(
|
||||
fn_service(|item: usize| Ready::<_, ()>::ok(item)),
|
||||
fn_service(|item: usize| Ready::<_, ()>::Ok(item)),
|
||||
|t: usize| {
|
||||
item.set(item.get() + t);
|
||||
},
|
||||
|
@ -327,7 +327,7 @@ mod tests {
|
|||
|
||||
#[ntex::test]
|
||||
async fn test_unit_config() {
|
||||
let _ = unit_config(fn_service(|item: usize| Ready::<_, ()>::ok(item)))
|
||||
let _ = unit_config(fn_service(|item: usize| Ready::<_, ()>::Ok(item)))
|
||||
.clone()
|
||||
.new_service(10)
|
||||
.await;
|
||||
|
@ -343,10 +343,10 @@ mod tests {
|
|||
let item = item2.clone();
|
||||
async move {
|
||||
item.set(next);
|
||||
Ok::<_, ()>(fn_service(|id: usize| Ready::<_, ()>::ok(id * 2)))
|
||||
Ok::<_, ()>(fn_service(|id: usize| Ready::<_, ()>::Ok(id * 2)))
|
||||
}
|
||||
}),
|
||||
fn_service(move |item: usize| Ready::<_, ()>::ok(item + 1)),
|
||||
fn_service(move |item: usize| Ready::<_, ()>::Ok(item + 1)),
|
||||
)
|
||||
.clone()
|
||||
.new_service(10)
|
||||
|
|
|
@ -225,7 +225,7 @@ mod tests {
|
|||
}
|
||||
|
||||
fn call(&self, _: ()) -> Self::Future {
|
||||
Ready::err(())
|
||||
Ready::Err(())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -257,7 +257,7 @@ mod tests {
|
|||
|
||||
#[ntex::test]
|
||||
async fn test_factory() {
|
||||
let new_srv = (|| Ready::<_, ()>::ok(Srv))
|
||||
let new_srv = (|| Ready::<_, ()>::Ok(Srv))
|
||||
.into_factory()
|
||||
.map_err(|_| "error")
|
||||
.clone();
|
||||
|
|
|
@ -278,8 +278,8 @@ mod tests {
|
|||
|
||||
fn call(&self, req: Result<&'static str, &'static str>) -> Self::Future {
|
||||
match req {
|
||||
Ok(msg) => Ready::ok(msg),
|
||||
Err(_) => Ready::err(()),
|
||||
Ok(msg) => Ready::Ok(msg),
|
||||
Err(_) => Ready::Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -299,8 +299,8 @@ mod tests {
|
|||
|
||||
fn call(&self, req: Result<&'static str, ()>) -> Self::Future {
|
||||
match req {
|
||||
Ok(msg) => Ready::ok((msg, "ok")),
|
||||
Err(()) => Ready::ok(("srv2", "err")),
|
||||
Ok(msg) => Ready::Ok((msg, "ok")),
|
||||
Err(()) => Ready::Ok(("srv2", "err")),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -334,9 +334,9 @@ mod tests {
|
|||
async fn test_factory() {
|
||||
let cnt = Rc::new(Cell::new(0));
|
||||
let cnt2 = cnt.clone();
|
||||
let blank = move || Ready::<_, ()>::ok(Srv1(cnt2.clone()));
|
||||
let blank = move || Ready::<_, ()>::Ok(Srv1(cnt2.clone()));
|
||||
let factory = pipeline_factory(blank)
|
||||
.then(move || Ready::ok(Srv2(cnt.clone())))
|
||||
.then(move || Ready::Ok(Srv2(cnt.clone())))
|
||||
.clone();
|
||||
let srv = factory.new_service(&()).await.unwrap();
|
||||
let res = srv.call(Ok("srv1")).await;
|
||||
|
|
|
@ -249,7 +249,7 @@ mod tests {
|
|||
type Future = Ready<Self::Transform, Self::InitError>;
|
||||
|
||||
fn new_transform(&self, service: S) -> Self::Future {
|
||||
Ready::ok(Srv(service))
|
||||
Ready::Ok(Srv(service))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -275,7 +275,7 @@ mod tests {
|
|||
async fn transform() {
|
||||
let factory = apply(
|
||||
Rc::new(Tr.map_init_err(|_| ()).clone()),
|
||||
fn_service(|i: usize| Ready::<_, ()>::ok(i * 2)),
|
||||
fn_service(|i: usize| Ready::<_, ()>::Ok(i * 2)),
|
||||
)
|
||||
.clone();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue