diff options
| author | Dawid Rycerz <dawid@rycerz.xyz> | 2025-07-14 19:34:59 +0300 |
|---|---|---|
| committer | Dawid Rycerz <dawid@rycerz.xyz> | 2025-07-14 19:34:59 +0300 |
| commit | 50ce8cb96b2b218751c2fc2a6b19372f51846acc (patch) | |
| tree | e2c634d2ce856062d527667d47815a05a53361c8 /src/lib.rs | |
| parent | 0ab2e5ba2b0631b28b5b1405559237b3913c878f (diff) | |
feat: rewrite in rust
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..f51483b --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,31 @@ +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\"}"); + } +} |
