1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-30 00:29:29 +02:00

Add helper function for executing futures test::block_fn()

This commit is contained in:
Nikolay Kim
2019-04-29 09:34:14 -07:00
parent 29a841529f
commit f4b4875cb1
3 changed files with 30 additions and 6 deletions

View File

@@ -445,7 +445,9 @@ mod tests {
use super::*;
use crate::http::{header, HeaderValue, Method, StatusCode};
use crate::service::{ServiceRequest, ServiceResponse};
use crate::test::{block_on, call_service, init_service, read_body, TestRequest};
use crate::test::{
block_fn, block_on, call_service, init_service, read_body, TestRequest,
};
use crate::{web, Error, HttpRequest, HttpResponse};
#[test]
@@ -454,7 +456,7 @@ mod tests {
App::new().service(web::resource("/test").to(|| HttpResponse::Ok())),
);
let req = TestRequest::with_uri("/test").to_request();
let resp = block_on(srv.call(req)).unwrap();
let resp = block_fn(|| srv.call(req)).unwrap();
assert_eq!(resp.status(), StatusCode::OK);
let req = TestRequest::with_uri("/blah").to_request();