diff options
Diffstat (limited to 'tests/test_router.rs')
-rw-r--r-- | tests/test_router.rs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/tests/test_router.rs b/tests/test_router.rs index 7ebe019..cfd4c32 100644 --- a/tests/test_router.rs +++ b/tests/test_router.rs @@ -1,11 +1,11 @@ -use macroblog::router::{Router}; +use macroblog::router::Router; #[test] fn test_router_new_posts() { - match Router::new("/posts/k8s.html") { + 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::Post { page } => assert_eq!(page, "k8s.html".to_string()) + Router::Post { page } => assert_eq!(page, "2021-12-26Enable_NFS_on_K3S.md".to_string()), }; } @@ -14,7 +14,7 @@ fn test_router_new_index() { match Router::new("/") { Router::Index => assert!(true), Router::NotFound => assert!(false, "Wrong type parse"), - Router::Post { page: _ } => assert!(false, "Wrong type parse") + Router::Post { page: _ } => assert!(false, "Wrong type parse"), }; } @@ -23,6 +23,15 @@ fn test_router_new_not_found() { match Router::new("/not_found") { Router::NotFound => assert!(true), Router::Index => assert!(false, "Wrong type parse"), - Router::Post { page: _ } => 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::Post { page: _ } => assert!(false, "Wrong type parse"), }; } |