From 0095491a204325fbc286c4bd30530589a4515eba Mon Sep 17 00:00:00 2001 From: Lennart <18233294+lennart-k@users.noreply.github.com> Date: Sun, 2 Nov 2025 22:17:23 +0100 Subject: [PATCH] frontend: dumb test for timezones --- crates/frontend/src/routes/timezones.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/crates/frontend/src/routes/timezones.rs b/crates/frontend/src/routes/timezones.rs index b4c75ed..8a3c1f5 100644 --- a/crates/frontend/src/routes/timezones.rs +++ b/crates/frontend/src/routes/timezones.rs @@ -1,4 +1,3 @@ -use axum::response::{IntoResponse, Response}; use headers::{CacheControl, ContentType, HeaderMapExt}; use http::{HeaderMap, HeaderValue, Method}; use itertools::Itertools; @@ -14,7 +13,7 @@ static VTIMEZONES_JSON: LazyLock = LazyLock::new(|| { .unwrap() }); -pub async fn route_timezones(method: Method) -> Response { +pub async fn route_timezones(method: Method) -> (HeaderMap, &'static str) { let mut headers = HeaderMap::new(); headers.typed_insert(ContentType::json()); headers.insert( @@ -24,7 +23,17 @@ pub async fn route_timezones(method: Method) -> Response { headers.typed_insert(CacheControl::new().with_max_age(Duration::from_hours(2))); if method == Method::HEAD { - return headers.into_response(); + return (headers, ""); } - (headers, VTIMEZONES_JSON.as_str()).into_response() + (headers, VTIMEZONES_JSON.as_str()) +} + +#[cfg(test)] +#[tokio::test] +async fn test_vtimezones_json() -> () { + // Since there's an unwrap make sure this doesn't fail + assert!(!VTIMEZONES_JSON.as_str().is_empty()); + + assert!(route_timezones(Method::HEAD).await.1.is_empty()); + assert!(!route_timezones(Method::GET).await.1.is_empty()); }