1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-31 17:07:01 +02:00

more tests

This commit is contained in:
Nikolay Kim
2019-03-12 22:57:09 -07:00
parent 28f01beaec
commit 86405cfe7a
4 changed files with 179 additions and 8 deletions

View File

@@ -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.
///