diff --git a/actix-framed/Cargo.toml b/actix-framed/Cargo.toml index a2919bcec..bbd7dd698 100644 --- a/actix-framed/Cargo.toml +++ b/actix-framed/Cargo.toml @@ -24,6 +24,7 @@ actix-codec = "0.1.2" actix-service = "0.3.6" actix-utils = "0.3.4" actix-router = "0.1.2" +actix-rt = "0.2.2" actix-http = { path = "../actix-http" } bytes = "0.4" @@ -31,7 +32,6 @@ futures = "0.1.25" log = "0.4" [dev-dependencies] -actix-rt = "0.2.2" actix-server = { version = "0.4.1", features=["ssl"] } actix-connect = { version = "0.1.0", features=["ssl"] } actix-http-test = { version = "0.1.0-alpha.3", features=["ssl"] } diff --git a/actix-framed/src/test.rs b/actix-framed/src/test.rs index 34a157279..3bc828df4 100644 --- a/actix-framed/src/test.rs +++ b/actix-framed/src/test.rs @@ -5,6 +5,8 @@ use actix_http::http::header::{Header, HeaderName, IntoHeaderValue}; use actix_http::http::{HttpTryFrom, Method, Uri, Version}; use actix_http::test::{TestBuffer, TestRequest as HttpTestRequest}; use actix_router::{Path, Url}; +use actix_rt::Runtime; +use futures::IntoFuture; use crate::{FramedRequest, State}; @@ -114,6 +116,16 @@ impl TestRequest { let framed = Framed::new(TestBuffer::empty(), Codec::default()); FramedRequest::new(req, framed, self.path, self.state) } + + /// This method generates `FramedRequest` instance and executes async handler + pub fn run(self, f: F) -> Result + where + F: FnOnce(FramedRequest) -> R, + R: IntoFuture, + { + let mut rt = Runtime::new().unwrap(); + rt.block_on(f(self.finish()).into_future()) + } } #[cfg(test)]