macroblog.rs @ 6a31a30b98f7febe9ac0db74211ef074aefc7ad3

 1use macroblog::router::Router;
 2
 3#[test]
 4fn test_router_new_posts() {
 5    match Router::new("/posts/2021-12-26Enable_NFS_on_K3S.md") {
 6        Router::NotFound => assert!(false, "Wrong type parse"),
 7        Router::Index => assert!(false, "Wrong type parse"),
 8        Router::Projects => assert!(false, "Wrong type parse"),
 9        Router::Post { page } => assert_eq!(page, "2021-12-26Enable_NFS_on_K3S.md".to_string()),
10    };
11}
12
13
14#[test]
15fn test_router_projects() {
16    match Router::new("/projects") {
17        Router::NotFound => assert!(false, "Wrong type parse"),
18        Router::Index => assert!(false, "Wrong type parse"),
19        Router::Projects => assert!(true),
20        Router::Post { page: _ } => assert!(false, "Wrong type parse"),
21    };
22}
23
24#[test]
25fn test_router_new_index() {
26    match Router::new("/") {
27        Router::Index => assert!(true),
28        Router::NotFound => assert!(false, "Wrong type parse"),
29        Router::Projects => assert!(false, "Wrong type parse"),
30        Router::Post { page: _ } => assert!(false, "Wrong type parse"),
31    };
32}
33
34#[test]
35fn test_router_new_not_found() {
36    match Router::new("/not_found") {
37        Router::NotFound => assert!(true),
38        Router::Index => assert!(false, "Wrong type parse"),
39        Router::Projects => assert!(false, "Wrong type parse"),
40        Router::Post { page: _ } => assert!(false, "Wrong type parse"),
41    };
42}
43
44#[test]
45fn test_router_new_not_found_matching_regex() {
46    match Router::new("/posts/2021-12-03Enable_NFS_on_K3S.html") {
47        Router::NotFound => assert!(true),
48        Router::Index => assert!(false, "Wrong type parse"),
49        Router::Projects => assert!(false, "Wrong type parse"),
50        Router::Post { page: _ } => assert!(false, "Wrong type parse"),
51    };
52}