use axum::{Router, routing::get}; pub fn app() -> Router { Router::new() .route("/health", get(crate::health::health_handler)) } pub mod users; pub mod locations; pub mod weather_thresholds; pub mod notifications; pub mod weather_poller; pub mod health; #[cfg(test)] mod tests { use super::*; use axum::body::Body; use axum::http::{Request, StatusCode}; use tower::ServiceExt; // for `oneshot` use axum::body::to_bytes; #[tokio::test] async fn test_health_endpoint() { let app = app(); let response = app.oneshot(Request::builder().uri("/health").body(Body::empty()).unwrap()).await.unwrap(); assert_eq!(response.status(), StatusCode::OK); let body = to_bytes(response.into_body(), 1024).await.unwrap(); assert_eq!(&body[..], b"{\"status\":\"ok\"}"); } }