frontend: dumb test for timezones

This commit is contained in:
Lennart
2025-11-02 22:17:23 +01:00
parent e9392cc00b
commit 0095491a20

View File

@@ -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<String> = 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());
}