mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 20:32:48 +00:00
frontend: dumb test for timezones
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
use axum::response::{IntoResponse, Response};
|
|
||||||
use headers::{CacheControl, ContentType, HeaderMapExt};
|
use headers::{CacheControl, ContentType, HeaderMapExt};
|
||||||
use http::{HeaderMap, HeaderValue, Method};
|
use http::{HeaderMap, HeaderValue, Method};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
@@ -14,7 +13,7 @@ static VTIMEZONES_JSON: LazyLock<String> = LazyLock::new(|| {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
});
|
});
|
||||||
|
|
||||||
pub async fn route_timezones(method: Method) -> Response {
|
pub async fn route_timezones(method: Method) -> (HeaderMap, &'static str) {
|
||||||
let mut headers = HeaderMap::new();
|
let mut headers = HeaderMap::new();
|
||||||
headers.typed_insert(ContentType::json());
|
headers.typed_insert(ContentType::json());
|
||||||
headers.insert(
|
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)));
|
headers.typed_insert(CacheControl::new().with_max_age(Duration::from_hours(2)));
|
||||||
|
|
||||||
if method == Method::HEAD {
|
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());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user