mirror of
https://github.com/tokio-rs/axum.git
synced 2026-09-02 00:00:22 +02:00
Add test for not hitting debug_assert in MatchedPath (#1935)
This commit is contained in:
@@ -172,11 +172,14 @@ fn append_nested_matched_path(matched_path: &Arc<str>, extensions: &http::Extens
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
handler::HandlerWithoutStateExt, middleware::map_request, routing::get, test_helpers::*,
|
body::Body,
|
||||||
|
handler::HandlerWithoutStateExt,
|
||||||
|
middleware::map_request,
|
||||||
|
routing::{any, get},
|
||||||
|
test_helpers::*,
|
||||||
Router,
|
Router,
|
||||||
};
|
};
|
||||||
use http::{Request, StatusCode};
|
use http::{Request, StatusCode};
|
||||||
use hyper::Body;
|
|
||||||
|
|
||||||
#[crate::test]
|
#[crate::test]
|
||||||
async fn extracting_on_handler() {
|
async fn extracting_on_handler() {
|
||||||
@@ -355,6 +358,26 @@ mod tests {
|
|||||||
assert_eq!(res.status(), StatusCode::OK);
|
assert_eq!(res.status(), StatusCode::OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/tokio-rs/axum/issues/1579
|
||||||
|
#[crate::test]
|
||||||
|
async fn doesnt_panic_if_router_called_from_wildcard_route() {
|
||||||
|
use tower::ServiceExt;
|
||||||
|
|
||||||
|
let app = Router::new().route(
|
||||||
|
"/*path",
|
||||||
|
any(|req: Request<Body>| {
|
||||||
|
Router::new()
|
||||||
|
.nest("/", Router::new().route("/foo", get(|| async {})))
|
||||||
|
.oneshot(req)
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
let client = TestClient::new(app);
|
||||||
|
|
||||||
|
let res = client.get("/foo").send().await;
|
||||||
|
assert_eq!(res.status(), StatusCode::OK);
|
||||||
|
}
|
||||||
|
|
||||||
#[crate::test]
|
#[crate::test]
|
||||||
async fn cant_extract_in_fallback() {
|
async fn cant_extract_in_fallback() {
|
||||||
async fn handler(path: Option<MatchedPath>, req: Request<Body>) {
|
async fn handler(path: Option<MatchedPath>, req: Request<Body>) {
|
||||||
|
|||||||
Reference in New Issue
Block a user