add basic backend
This commit is contained in:
26
backend/tests/healthcheck.rs
Normal file
26
backend/tests/healthcheck.rs
Normal file
@ -0,0 +1,26 @@
|
||||
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}"#));
|
||||
}
|
||||
Reference in New Issue
Block a user