You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
817 B
Rust

//! Integration tests for the health check endpoint.
//!
//! Requires a running Postgres instance. Set `TEST_DATABASE_URL` to run.
//! Tests are skipped (ignored) when the env var is not present.
mod common;
use axum::http::StatusCode;
/// Helper: skip if TEST_DATABASE_URL is not set.
fn require_test_db() -> bool {
std::env::var("TEST_DATABASE_URL").is_ok()
}
#[tokio::test]
async fn health_check_returns_200() {
if !require_test_db() {
eprintln!("SKIPPED: TEST_DATABASE_URL not set");
return;
}
let app = common::TestApp::new().await;
let (status, body) = app.get("/api/v1/health").await;
assert_eq!(status, StatusCode::OK, "Health check should return 200");
assert_eq!(
body["status"], "ok",
"Health check body should contain status: ok"
);
}