diff options
author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2022-05-08 21:47:45 +0200 |
---|---|---|
committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2022-05-08 21:47:45 +0200 |
commit | ea058a851098bf81cb645249e02d26a8c253db90 (patch) | |
tree | c245a133119b1a4bf6168a16c89b22b6e04d319e /tests | |
parent | 189166e2f44ca69537fa632032ec7ab252595d1b (diff) | |
download | macroblog.rs-ea058a851098bf81cb645249e02d26a8c253db90.tar.gz macroblog.rs-ea058a851098bf81cb645249e02d26a8c253db90.tar.bz2 macroblog.rs-ea058a851098bf81cb645249e02d26a8c253db90.zip |
ref: Add embded rust and router
- Use embed rust to load and resolve file from `content/post` folder, so
the whole process is a bit more dynamic.
- Add router to to resolve the path. It is the first step to try to get
the code a bit cleaner.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_router.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test_router.rs b/tests/test_router.rs new file mode 100644 index 0000000..0158d78 --- /dev/null +++ b/tests/test_router.rs @@ -0,0 +1,28 @@ +use router::{Router}; + +#[test] +fn test_router_new_posts() { + match Router::new("/posts/k8s.html") { + Router::NotFound => assert!(false, "Wrong type parse"), + Router::Index => assert!(false, "Wrong type parse"), + Router::Post { page } => assert_eq!(page, "k8s.html".to_string()) + }; +} + +#[test] +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") + }; +} + +#[test] +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") + }; +} |