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 Oct 11, 2024
1 parent c497572 commit 2d156dd
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 2d156dd

Please sign in to comment.