mirror of
https://github.com/fafhrd91/actix-web
synced 2025-08-31 17:07:01 +02:00
more tests
This commit is contained in:
13
src/test.rs
13
src/test.rs
@@ -12,7 +12,7 @@ use actix_server_config::ServerConfig;
|
||||
use actix_service::{IntoNewService, NewService, Service};
|
||||
use bytes::Bytes;
|
||||
use cookie::Cookie;
|
||||
use futures::Future;
|
||||
use futures::future::{lazy, Future};
|
||||
|
||||
use crate::config::{AppConfig, AppConfigInner};
|
||||
use crate::rmap::ResourceMap;
|
||||
@@ -42,6 +42,17 @@ where
|
||||
RT.with(move |rt| rt.borrow_mut().block_on(f))
|
||||
}
|
||||
|
||||
/// Runs the provided function, with runtime enabled.
|
||||
///
|
||||
/// Note that this function is intended to be used only for testing purpose.
|
||||
/// This function panics on nested call.
|
||||
pub fn run_on<F, I, E>(f: F) -> Result<I, E>
|
||||
where
|
||||
F: Fn() -> Result<I, E>,
|
||||
{
|
||||
RT.with(move |rt| rt.borrow_mut().block_on(lazy(|| f())))
|
||||
}
|
||||
|
||||
/// This method accepts application builder instance, and constructs
|
||||
/// service.
|
||||
///
|
||||
|
Reference in New Issue
Block a user