2021-04-08 22:53:29 +02:00
|
|
|
/// In here, any non-unit tests are placed.
|
2021-04-04 19:22:53 +02:00
|
|
|
use rocket::http::Status;
|
|
|
|
use rocket::local::Client;
|
2021-04-02 21:20:36 +02:00
|
|
|
|
2021-04-04 19:22:53 +02:00
|
|
|
fn rocket() -> rocket::Rocket {
|
2021-04-08 22:39:04 +02:00
|
|
|
rocket::ignite().mount("/", fej_lib::ivago::routes())
|
2021-04-04 19:22:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/// 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);
|
2021-04-08 22:53:29 +02:00
|
|
|
// TODO add text check as well
|
2021-04-04 19:22:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Test 404 on invalid parameters
|
2021-04-08 22:53:29 +02:00
|
|
|
// TODO make this check a 400 instead
|
2021-04-04 19:22:53 +02:00
|
|
|
#[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);
|
|
|
|
}
|