Files
nuchat/backend/tests/healthcheck.rs
2025-07-21 17:18:00 +01:00

27 lines
713 B
Rust

use std::{sync::LazyLock, time::Duration};
use http::StatusCode;
use reqwest::Client;
static client: LazyLock<Client> = LazyLock::new(|| {
Client::builder()
.timeout(Duration::from_secs(10))
.connect_timeout(Duration::from_secs(5))
.build()
.expect("Could not build reqwest client")
});
#[tokio::test]
async fn test_healthcheck_returns_healthy() {
let resp = client
.get("http://localhost:7001/healthcheck")
.send()
.await
.expect("Could not get server");
assert_eq!(resp.status(), StatusCode::OK);
let body = resp.text().await.expect("Could not get response text");
assert_eq!(body, String::from(r#"{"healthy":true}"#));
}