mirror of
https://github.com/ntex-rs/ntex.git
synced 2025-04-03 21:07:39 +03:00
merge actix-rt
This commit is contained in:
parent
4ec01db40a
commit
7df3cc59a1
86 changed files with 582 additions and 587 deletions
|
@ -20,4 +20,4 @@ futures-util = "0.3.1"
|
|||
pin-project = "0.4.6"
|
||||
|
||||
[dev-dependencies]
|
||||
actix-rt = "1.0.0"
|
||||
ntex-rt = "1.0"
|
1
ntex-service/LICENSE
Symbolic link
1
ntex-service/LICENSE
Symbolic link
|
@ -0,0 +1 @@
|
|||
../LICENSE
|
|
@ -313,7 +313,7 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
#[ntex_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()));
|
||||
|
@ -322,7 +322,7 @@ mod tests {
|
|||
assert_eq!(cnt.get(), 2);
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
#[ntex_rt::test]
|
||||
async fn test_call() {
|
||||
let cnt = Rc::new(Cell::new(0));
|
||||
let mut srv = pipeline(Srv1(cnt.clone())).and_then(Srv2(cnt));
|
||||
|
@ -331,7 +331,7 @@ mod tests {
|
|||
assert_eq!(res.unwrap(), (("srv1", "srv2")));
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
#[ntex_rt::test]
|
||||
async fn test_new_service() {
|
||||
let cnt = Rc::new(Cell::new(0));
|
||||
let cnt2 = cnt.clone();
|
||||
|
|
|
@ -311,7 +311,7 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
#[ntex_rt::test]
|
||||
async fn test_service() {
|
||||
let mut srv = pipeline(|r: &'static str| ok(r))
|
||||
.and_then_apply_fn(Srv, |req: &'static str, s| {
|
||||
|
@ -325,7 +325,7 @@ mod tests {
|
|||
assert_eq!(res.unwrap(), ("srv", ()));
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
#[ntex_rt::test]
|
||||
async fn test_service_factory() {
|
||||
let new_srv =
|
||||
pipeline_factory(|| ok::<_, ()>(fn_service(|r: &'static str| ok(r))))
|
||||
|
|
|
@ -238,7 +238,7 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
#[ntex_rt::test]
|
||||
async fn test_call() {
|
||||
let mut srv = pipeline(apply_fn(Srv, |req: &'static str, srv| {
|
||||
let fut = srv.call(());
|
||||
|
@ -255,7 +255,7 @@ mod tests {
|
|||
assert_eq!(res.unwrap(), (("srv", ())));
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
#[ntex_rt::test]
|
||||
async fn test_new_service() {
|
||||
let new_srv = pipeline_factory(apply_fn_factory(
|
||||
|| ok::<_, ()>(Srv),
|
||||
|
|
|
@ -23,7 +23,7 @@ where
|
|||
///
|
||||
/// ```rust
|
||||
/// use std::io;
|
||||
/// use actix_service::{fn_factory, fn_service, Service, ServiceFactory};
|
||||
/// use ntex_service::{fn_factory, fn_service, Service, ServiceFactory};
|
||||
/// use futures_util::future::ok;
|
||||
///
|
||||
/// /// Service that divides two usize values.
|
||||
|
@ -35,7 +35,7 @@ where
|
|||
/// }
|
||||
/// }
|
||||
///
|
||||
/// #[actix_rt::main]
|
||||
/// #[ntex::main]
|
||||
/// async fn main() -> io::Result<()> {
|
||||
/// // Create service factory that produces `div` services
|
||||
/// let factory = fn_factory(|| {
|
||||
|
@ -73,10 +73,10 @@ where
|
|||
///
|
||||
/// ```rust
|
||||
/// use std::io;
|
||||
/// use actix_service::{fn_factory_with_config, fn_service, Service, ServiceFactory};
|
||||
/// use ntex_service::{fn_factory_with_config, fn_service, Service, ServiceFactory};
|
||||
/// use futures_util::future::ok;
|
||||
///
|
||||
/// #[actix_rt::main]
|
||||
/// #[ntex::main]
|
||||
/// async fn main() -> io::Result<()> {
|
||||
/// // Create service factory. factory uses config argument for
|
||||
/// // services it generates.
|
||||
|
@ -370,7 +370,7 @@ mod tests {
|
|||
use super::*;
|
||||
use crate::{Service, ServiceFactory};
|
||||
|
||||
#[actix_rt::test]
|
||||
#[ntex_rt::test]
|
||||
async fn test_fn_service() {
|
||||
let new_srv = fn_service(|()| ok::<_, ()>("srv"));
|
||||
|
||||
|
@ -381,7 +381,7 @@ mod tests {
|
|||
assert_eq!(res.unwrap(), "srv");
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
#[ntex_rt::test]
|
||||
async fn test_fn_service_service() {
|
||||
let mut srv = fn_service(|()| ok::<_, ()>("srv"));
|
||||
|
||||
|
@ -391,7 +391,7 @@ mod tests {
|
|||
assert_eq!(res.unwrap(), "srv");
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
#[ntex_rt::test]
|
||||
async fn test_fn_service_with_config() {
|
||||
let new_srv = fn_factory_with_config(|cfg: usize| {
|
||||
ok::<_, ()>(fn_service(move |()| ok::<_, ()>(("srv", cfg))))
|
||||
|
|
|
@ -226,14 +226,14 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
#[ntex_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(())));
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
#[ntex_rt::test]
|
||||
async fn test_call() {
|
||||
let mut srv = Srv.map(|_| "ok");
|
||||
let res = srv.call(()).await;
|
||||
|
@ -241,7 +241,7 @@ mod tests {
|
|||
assert_eq!(res.unwrap(), "ok");
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
#[ntex_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();
|
||||
|
|
|
@ -228,14 +228,14 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
#[ntex_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")));
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
#[ntex_rt::test]
|
||||
async fn test_call() {
|
||||
let mut srv = Srv.map_err(|_| "error");
|
||||
let res = srv.call(()).await;
|
||||
|
@ -243,7 +243,7 @@ mod tests {
|
|||
assert_eq!(res.err().unwrap(), "error");
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
#[ntex_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();
|
||||
|
|
|
@ -306,7 +306,7 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
#[ntex_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()));
|
||||
|
@ -315,7 +315,7 @@ mod tests {
|
|||
assert_eq!(cnt.get(), 2);
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
#[ntex_rt::test]
|
||||
async fn test_call() {
|
||||
let cnt = Rc::new(Cell::new(0));
|
||||
let mut srv = pipeline(Srv1(cnt.clone())).then(Srv2(cnt));
|
||||
|
@ -329,7 +329,7 @@ mod tests {
|
|||
assert_eq!(res.unwrap(), (("srv2", "err")));
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
#[ntex_rt::test]
|
||||
async fn test_factory() {
|
||||
let cnt = Rc::new(Cell::new(0));
|
||||
let cnt2 = cnt.clone();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue