mirror of
https://github.com/actix/actix-extras.git
synced 2025-06-27 18:49:01 +02:00
use actix_rt::test for test setup
This commit is contained in:
@ -7,7 +7,6 @@ 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 crate::{FramedRequest, State};
|
||||
|
||||
@ -119,13 +118,12 @@ impl<S> TestRequest<S> {
|
||||
}
|
||||
|
||||
/// This method generates `FramedRequest` instance and executes async handler
|
||||
pub fn run<F, R, I, E>(self, f: F) -> Result<I, E>
|
||||
pub async fn run<F, R, I, E>(self, f: F) -> Result<I, E>
|
||||
where
|
||||
F: FnOnce(FramedRequest<TestBuffer, S>) -> R,
|
||||
R: Future<Output = Result<I, E>>,
|
||||
{
|
||||
let mut rt = Runtime::new().unwrap();
|
||||
rt.block_on(f(self.finish()))
|
||||
f(self.finish()).await
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user