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
|
use macroblog::router::Router;
#[test]
fn test_router_new_posts() {
match Router::new("/posts/2021-12-26Enable_NFS_on_K3S.md") {
Router::NotFound => assert!(false, "Wrong type parse"),
Router::Index => assert!(false, "Wrong type parse"),
Router::Projects => assert!(false, "Wrong type parse"),
Router::Post { page } => assert_eq!(page, "2021-12-26Enable_NFS_on_K3S.md".to_string()),
};
}
#[test]
fn test_router_projects() {
match Router::new("/projects") {
Router::NotFound => assert!(false, "Wrong type parse"),
Router::Index => assert!(false, "Wrong type parse"),
Router::Projects => assert!(true),
Router::Post { page: _ } => assert!(false, "Wrong type parse"),
};
}
#[test]
fn test_router_new_index() {
match Router::new("/") {
Router::Index => assert!(true),
Router::NotFound => assert!(false, "Wrong type parse"),
Router::Projects => assert!(false, "Wrong type parse"),
Router::Post { page: _ } => assert!(false, "Wrong type parse"),
};
}
#[test]
fn test_router_new_not_found() {
match Router::new("/not_found") {
Router::NotFound => assert!(true),
Router::Index => assert!(false, "Wrong type parse"),
Router::Projects => assert!(false, "Wrong type parse"),
Router::Post { page: _ } => assert!(false, "Wrong type parse"),
};
}
#[test]
fn test_router_new_not_found_matching_regex() {
match Router::new("/posts/2021-12-03Enable_NFS_on_K3S.html") {
Router::NotFound => assert!(true),
Router::Index => assert!(false, "Wrong type parse"),
Router::Projects => assert!(false, "Wrong type parse"),
Router::Post { page: _ } => assert!(false, "Wrong type parse"),
};
}
|