fej/tests/ivago.rs

30 lines
838 B
Rust

/// In here, any non-unit tests are placed.
use rocket::http::Status;
use rocket::local::Client;
fn rocket() -> rocket::Rocket {
rocket::ignite().mount("/", fej_lib::ivago::routes())
}
/// Test 404 response
#[test]
fn test_404_response() {
let client = Client::new(rocket()).expect("valid rocket instance");
let response = client.get("/").dispatch();
assert_eq!(response.status(), Status::NotFound);
// TODO add text check as well
}
/// Test 404 on invalid parameters
// TODO make this check a 400 instead
#[test]
fn test_invalid_parameters() {
let client = Client::new(rocket()).expect("valid rocket instance");
let response = client
.get("/?street=astreet+(city)&number=500&start_date=2021-04-04&end_date=2021-04-555")
.dispatch();
assert_eq!(response.status(), Status::NotFound);
}