better test coverage for static resources

This commit is contained in:
shockrahwow 2019-11-27 23:41:16 -08:00
parent f4ec6102c3
commit 4a1be90cdf

View File

@ -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");
}
}