Add tests for the static file handler

This commit is contained in:
Paul van Tilburg 2018-01-01 21:16:55 +01:00
parent 8863b87c4e
commit 3251d098bd
1 changed files with 16 additions and 0 deletions

View File

@ -5,3 +5,19 @@ use rocket::response::NamedFile;
fn all(path: PathBuf) -> Option<NamedFile> {
NamedFile::open(Path::new("static/").join(path)).ok()
}
#[cfg(test)]
mod tests {
use rocket;
use rocket::http::Status;
use rocket::local::Client;
#[test]
fn all() {
let client = Client::new(rocket(Some("test"))).unwrap();
// Try to get the main JavaScript file
let res = client.get("/js/wishlists.js").dispatch();
assert_eq!(res.status(), Status::Ok);
}
}