Skip to content

Commit

Permalink
add test for method not allowed fallback with state
Browse files Browse the repository at this point in the history
  • Loading branch information
Lachstec committed Sep 29, 2024
1 parent bcb2579 commit 6cd8386
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions axum/src/routing/tests/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,15 @@ async fn mna_fallback_with_existing_fallback() {
"method not allowed fallback"
);
}

#[crate::test]
async fn mna_fallback_with_state() {
let app = Router::new()
.route("/", get(|| async { "index" }))
.method_not_allowed_fallback(|State(state): State<&'static str>| async move { state })
.with_state("state");

let client = TestClient::new(app);
let res = client.post("/").await;
assert_eq!(res.text().await, "state");
}

0 comments on commit 6cd8386

Please sign in to comment.