Skip to content

Commit

Permalink
It works \o/
Browse files Browse the repository at this point in the history
  • Loading branch information
jplatte committed Sep 17, 2022
1 parent 3e68a16 commit d855343
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions axum/src/routing/tests/merge.rs
Expand Up @@ -500,3 +500,18 @@ async fn merging_routes_different_paths_different_states() {
assert_eq!(res.status(), StatusCode::OK);
assert_eq!(res.text().await, "bar state");
}

#[tokio::test]
async fn inherit_state_via_merge() {
let foo = Router::inherit_state().route(
"/foo",
get(|State(state): State<&'static str>| async move { state }),
);

let app = Router::with_state("state").merge(foo);
let client = TestClient::new(app);

let res = client.get("/foo").send().await;
assert_eq!(res.status(), StatusCode::OK);
assert_eq!(res.text().await, "state");
}

0 comments on commit d855343

Please sign in to comment.