mirror of https://github.com/fafhrd91/actix-web
add nested configure test
This commit is contained in:
parent
5bd2a522f9
commit
8d1f61fb9d
|
@ -275,7 +275,7 @@ mod tests {
|
|||
|
||||
use super::*;
|
||||
use crate::http::{Method, StatusCode};
|
||||
use crate::test::{call_service, init_service, read_body, TestRequest};
|
||||
use crate::test::{assert_body_eq, call_service, init_service, read_body, TestRequest};
|
||||
use crate::{web, App, HttpRequest, HttpResponse};
|
||||
|
||||
// allow deprecated `ServiceConfig::data`
|
||||
|
@ -374,4 +374,22 @@ mod tests {
|
|||
let resp = call_service(&srv, req).await;
|
||||
assert_eq!(resp.status(), StatusCode::OK);
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn nested_service_configure() {
|
||||
fn cfg_root(cfg: &mut ServiceConfig) {
|
||||
cfg.configure(cfg_sub);
|
||||
}
|
||||
|
||||
fn cfg_sub(cfg: &mut ServiceConfig) {
|
||||
cfg.route("/", web::get().to(|| async { "hello world" }));
|
||||
}
|
||||
|
||||
let srv = init_service(App::new().configure(cfg_root)).await;
|
||||
|
||||
let req = TestRequest::with_uri("/").to_request();
|
||||
let res = call_service(&srv, req).await;
|
||||
assert_eq!(res.status(), StatusCode::OK);
|
||||
assert_body_eq!(res, b"hello world");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue