refactor: drop postgres leftovers, narrow bootstrap api

This commit is contained in:
2026-10-25 23:25:16 +01:00
parent ec2760fd48
commit b7e69b69dc
16 changed files with 277 additions and 58 deletions

View File

@@ -359,3 +359,49 @@ async fn admin_user_surfaces_a_repository_error_as_500() {
.unwrap();
assert_eq!(resp.status(), StatusCode::INTERNAL_SERVER_ERROR);
}
async fn path_id_handler(
http_axum::extractors::PathId(id): http_axum::extractors::PathId<u32>,
) -> String {
id.to_string()
}
async fn refusal_code(resp: axum::response::Response) -> String {
let bytes = axum::body::to_bytes(resp.into_body(), usize::MAX)
.await
.unwrap();
let v: serde_json::Value = serde_json::from_slice(&bytes).expect("refusal body is JSON");
v["code"].as_str().unwrap().to_string()
}
#[tokio::test]
async fn path_extractor_on_a_route_without_params_is_refused_as_internal() {
let app = Router::new().route("/no-params", get(path_id_handler));
let resp = app
.oneshot(
Request::builder()
.uri("/no-params")
.body(Body::empty())
.unwrap(),
)
.await
.unwrap();
assert_eq!(resp.status(), StatusCode::INTERNAL_SERVER_ERROR);
assert_eq!(refusal_code(resp).await, "INTERNAL");
}
#[tokio::test]
async fn path_extractor_with_an_unparseable_param_is_refused_as_invalid_input() {
let app = Router::new().route("/items/{id}", get(path_id_handler));
let resp = app
.oneshot(
Request::builder()
.uri("/items/abc")
.body(Body::empty())
.unwrap(),
)
.await
.unwrap();
assert_eq!(resp.status(), StatusCode::BAD_REQUEST);
assert_eq!(refusal_code(resp).await, "INVALID_INPUT");
}