-
Notifications
You must be signed in to change notification settings - Fork 36
/
l10n.rs
66 lines (60 loc) · 1.79 KB
/
l10n.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
pub mod common;
use agama_server::l10n::web::l10n_service;
use axum::{
body::Body,
http::{Request, StatusCode},
Router,
};
use common::body_to_string;
use tokio::{sync::broadcast::channel, test};
use tower::ServiceExt;
fn build_service() -> Router {
let (tx, _) = channel(16);
l10n_service(tx)
}
#[test]
async fn test_get_config() {
let service = build_service();
let request = Request::builder()
.uri("/config")
.body(Body::empty())
.unwrap();
let response = service.oneshot(request).await.unwrap();
assert_eq!(response.status(), StatusCode::OK);
}
#[test]
async fn test_locales() {
let service = build_service();
let request = Request::builder()
.uri("/locales")
.body(Body::empty())
.unwrap();
let response = service.oneshot(request).await.unwrap();
assert_eq!(response.status(), StatusCode::OK);
let body = body_to_string(response.into_body()).await;
assert!(body.contains(r#""language":"English""#));
}
#[test]
async fn test_keymaps() {
let service = build_service();
let request = Request::builder()
.uri("/keymaps")
.body(Body::empty())
.unwrap();
let response = service.oneshot(request).await.unwrap();
assert_eq!(response.status(), StatusCode::OK);
let body = body_to_string(response.into_body()).await;
assert!(body.contains(r#""id":"us""#));
}
#[test]
async fn test_timezones() {
let service = build_service();
let request = Request::builder()
.uri("/timezones")
.body(Body::empty())
.unwrap();
let response = service.oneshot(request).await.unwrap();
assert_eq!(response.status(), StatusCode::OK);
let body = body_to_string(response.into_body()).await;
assert!(body.contains(r#""code":"Atlantic/Canary""#));
}