Files
biggus-dickus/crates/server/tests/serve.rs
T
logaritmisk d15afda9b2 feat(api): on-write search reindex after catalogue writes (#17)
Wire best-effort Meilisearch index sync into the admin write paths
(create/update/delete/set_fields/set_visibility). Adds
SearchClient::sync_object (reindex if the object exists, remove if gone —
one uniform path), an optional AppState.search client, and a reindex
helper that logs failures via tracing without failing the committed
write. Server gains MEILI_URL/MEILI_MASTER_KEY/MEILI_INDEX config;
search stays disabled (no-op) when unset. reindex_all remains the
recovery path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-02 23:25:43 +02:00

40 lines
1011 B
Rust

use std::net::SocketAddr;
use api::AppState;
use db::Db;
use server::serve;
use tokio::net::TcpListener;
#[tokio::test]
async fn serves_health_live_over_tcp() {
let database_url =
std::env::var("DATABASE_URL").expect("DATABASE_URL must be set for this test");
let db = Db::connect(&database_url)
.await
.expect("connect to database");
let state = AppState {
db,
app_name: "Test".to_string(),
cookie_secure: false,
search: None,
};
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 url = format!("http://{addr}/health/live");
let body: serde_json::Value = reqwest::get(&url)
.await
.expect("request succeeds")
.json()
.await
.expect("json body");
assert_eq!(body["status"], "ok");
handle.abort();
}