mod common; use axum::body::Body; use axum::http::{Request, StatusCode}; use tower::util::ServiceExt; use common::TestConfig; #[tokio::test] async fn health_returns_ok() { let app = doctate_server::create_router(TestConfig::new().with_label("health").build()); let response = app .oneshot( Request::builder() .uri("/api/health") .body(Body::empty()) .unwrap(), ) .await .unwrap(); assert_eq!(response.status(), StatusCode::OK); } #[tokio::test] async fn health_returns_json_with_status() { let app = doctate_server::create_router(TestConfig::new().with_label("health").build()); let response = app .oneshot( Request::builder() .uri("/api/health") .body(Body::empty()) .unwrap(), ) .await .unwrap(); let json = common::body_json(response).await; assert_eq!(json["status"], "ok"); assert_eq!(json["port"], 3000); }