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::Post { page } => assert_eq!(page, "2021-12-26Enable_NFS_on_K3S.md".to_string()),
9 };
10}
11
12#[test]
13fn test_router_new_index() {
14 match Router::new("/") {
15 Router::Index => assert!(true),
16 Router::NotFound => assert!(false, "Wrong type parse"),
17 Router::Post { page: _ } => assert!(false, "Wrong type parse"),
18 };
19}
20
21#[test]
22fn test_router_new_not_found() {
23 match Router::new("/not_found") {
24 Router::NotFound => assert!(true),
25 Router::Index => assert!(false, "Wrong type parse"),
26 Router::Post { page: _ } => assert!(false, "Wrong type parse"),
27 };
28}
29
30#[test]
31fn test_router_new_not_found_matching_regex() {
32 match Router::new("/posts/2021-12-03Enable_NFS_on_K3S.html") {
33 Router::NotFound => assert!(true),
34 Router::Index => assert!(false, "Wrong type parse"),
35 Router::Post { page: _ } => assert!(false, "Wrong type parse"),
36 };
37}