better test coverage for static resources
This commit is contained in:
parent
f4ec6102c3
commit
4a1be90cdf
@ -36,7 +36,7 @@ fn rocket() -> rocket::Rocket {
|
|||||||
.mount("/static", StaticFiles::from("/static"))
|
.mount("/static", StaticFiles::from("/static"))
|
||||||
.mount("/", routes![
|
.mount("/", routes![
|
||||||
homepage, about_page, server_info,
|
homepage, about_page, server_info,
|
||||||
static_css,
|
static_css, static_js, static_media
|
||||||
])
|
])
|
||||||
.attach(Template::fairing())
|
.attach(Template::fairing())
|
||||||
}
|
}
|
||||||
@ -52,6 +52,12 @@ mod test {
|
|||||||
use rocket::local::Client;
|
use rocket::local::Client;
|
||||||
use rocket::http::Status;
|
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]
|
#[test]
|
||||||
fn test_homepage() {
|
fn test_homepage() {
|
||||||
// Just make sure that when request the home page we actually get the html back
|
// Just make sure that when request the home page we actually get the html back
|
||||||
@ -63,7 +69,8 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn statics() {
|
fn statics() {
|
||||||
let client = Client::new(rocket()).expect("Valid rocket instance");
|
let client = Client::new(rocket()).expect("Valid rocket instance");
|
||||||
let response = client.get("/static/css/index.css").dispatch();
|
check_get!(client, "/static/index.css");
|
||||||
assert_eq!(response.status(), Status::Ok);
|
check_get!(client, "/static/css/about.css");
|
||||||
|
check_get!(client, "/static/media/favicon.png");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user