diff options
author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2022-06-11 00:00:27 +0200 |
---|---|---|
committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2022-06-11 00:00:27 +0200 |
commit | 4fb323f69c11557a51c7da0b2031029f63edf789 (patch) | |
tree | 0d08ce52abbe0c5d123b4051f50ec5bc386652ae /tests | |
parent | 0e147a780e74b54afbd56ff7438077d855d5c1c2 (diff) | |
download | macroblog.rs-4fb323f69c11557a51c7da0b2031029f63edf789.tar.gz macroblog.rs-4fb323f69c11557a51c7da0b2031029f63edf789.tar.bz2 macroblog.rs-4fb323f69c11557a51c7da0b2031029f63edf789.zip |
feat: Handle 404 result
Now gracefully handle 404, so instead of just panic now it will return a
proper http 404 response.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_blog.rs | 3 | ||||
-rw-r--r-- | tests/test_router.rs | 19 |
2 files changed, 16 insertions, 6 deletions
diff --git a/tests/test_blog.rs b/tests/test_blog.rs index b72f800..6cd3249 100644 --- a/tests/test_blog.rs +++ b/tests/test_blog.rs @@ -1,4 +1,5 @@ use macroblog::blog::*; +use macroblog::assets::*; use chrono::NaiveDate; @@ -17,7 +18,7 @@ fn test_create_blog_entry() { #[test] fn test_read_assets() { // This test meant to test if all files are parsed correctly - let assets = BlogEntry::read_assets(); + let assets = read_assets(); assert!(assets.iter().count() > 1) } 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"), }; } |