From 4a1be90cdf2520417174b878298f33874dc31d44 Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Wed, 27 Nov 2019 23:41:16 -0800 Subject: [PATCH] better test coverage for static resources --- server/src/main.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/server/src/main.rs b/server/src/main.rs index d6d154e..6eb89c1 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -36,7 +36,7 @@ fn rocket() -> rocket::Rocket { .mount("/static", StaticFiles::from("/static")) .mount("/", routes![ homepage, about_page, server_info, - static_css, + static_css, static_js, static_media ]) .attach(Template::fairing()) } @@ -52,6 +52,12 @@ mod test { use rocket::local::Client; use rocket::http::Status; + macro_rules! check_get { + ($client:expr, $file:expr) => { + let response = $client.get($file).dispatch(); + assert_eq!(response.status(), Status::Ok); + } + } #[test] fn test_homepage() { // Just make sure that when request the home page we actually get the html back @@ -63,7 +69,8 @@ mod test { #[test] fn statics() { let client = Client::new(rocket()).expect("Valid rocket instance"); - let response = client.get("/static/css/index.css").dispatch(); - assert_eq!(response.status(), Status::Ok); + check_get!(client, "/static/index.css"); + check_get!(client, "/static/css/about.css"); + check_get!(client, "/static/media/favicon.png"); } }