[#13] Further overhaul of the project structure for better testing
This commit is contained in:
parent
e78de73d83
commit
2e73d88ae9
10 changed files with 48 additions and 16 deletions
26
tests/ivago.rs
Normal file
26
tests/ivago.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
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);
|
||||
}
|
||||
|
||||
/// Test 404 on invalid parameters
|
||||
#[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);
|
||||
}
|
||||
Reference in a new issue