From 1a91b8a242ff415bb92cb04cc6fa8cd41fe5e239 Mon Sep 17 00:00:00 2001 From: Anders Olsson Date: Thu, 4 Jun 2026 17:21:33 +0200 Subject: [PATCH] chore: cross-ref enum/CHECK constraints (#9); drop dead clone + harden smoke test (#4) Co-Authored-By: Claude Sonnet 4.6 --- crates/domain/src/audit.rs | 4 ++++ crates/domain/src/authority.rs | 4 ++++ crates/server/src/lib.rs | 2 +- crates/server/tests/serve.rs | 18 +++++++++++++----- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/crates/domain/src/audit.rs b/crates/domain/src/audit.rs index f9d7114..238dd3c 100644 --- a/crates/domain/src/audit.rs +++ b/crates/domain/src/audit.rs @@ -4,6 +4,10 @@ use time::OffsetDateTime; use uuid::Uuid; /// What kind of change an audit entry records. +/// +/// NOTE: kept in sync by hand with the +/// `CHECK (action IN ('created', 'updated', 'deleted'))` constraint in +/// `crates/db/migrations/0001_audit_log.sql` — add a variant in both places. #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] pub enum AuditAction { diff --git a/crates/domain/src/authority.rs b/crates/domain/src/authority.rs index 299b1a1..7cc550e 100644 --- a/crates/domain/src/authority.rs +++ b/crates/domain/src/authority.rs @@ -3,6 +3,10 @@ use serde::{Deserialize, Serialize}; use crate::{AuthorityId, LocalizedLabel}; /// The kind of authority record. +/// +/// NOTE: kept in sync by hand with the +/// `CHECK (kind IN ('person', 'organisation', 'place'))` constraint in +/// `crates/db/migrations/0002_vocabularies_authorities.sql` — add a variant in both places. #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] pub enum AuthorityKind { diff --git a/crates/server/src/lib.rs b/crates/server/src/lib.rs index ae630b8..a355cd6 100644 --- a/crates/server/src/lib.rs +++ b/crates/server/src/lib.rs @@ -50,7 +50,7 @@ pub async fn run(config: Config) -> anyhow::Result<()> { let state = AppState { db, - app_name: config.app_name.clone(), + app_name: config.app_name, cookie_secure: config.cookie_secure, search, }; diff --git a/crates/server/tests/serve.rs b/crates/server/tests/serve.rs index aa15497..b3dd99d 100644 --- a/crates/server/tests/serve.rs +++ b/crates/server/tests/serve.rs @@ -22,13 +22,21 @@ async fn serves_health_live_over_tcp() { let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); let addr: SocketAddr = listener.local_addr().unwrap(); - let handle = tokio::spawn(async move { - serve(listener, state).await.unwrap(); - }); + let handle = tokio::spawn(async move { serve(listener, state).await }); let url = format!("http://{addr}/health/live"); - let body: serde_json::Value = reqwest::get(&url) - .await + let response = reqwest::get(&url).await; + + // If the request failed and the server task already ended, it errored — surface that + // (a clear server error) instead of the opaque reqwest failure. + if response.is_err() && handle.is_finished() { + match handle.await { + Ok(Err(err)) => panic!("server failed: {err:?}"), + other => panic!("server task ended unexpectedly: {other:?}"), + } + } + + let body: serde_json::Value = response .expect("request succeeds") .json() .await