25 lines
735 B
Rust
25 lines
735 B
Rust
|
use rocket::local::Client;
|
||
|
use rocket::http::Status;
|
||
|
|
||
|
fn rocket() -> rocket::Rocket {
|
||
|
rocket::ignite().mount("/", routes![super::world, super::hello, super::name_age])
|
||
|
}
|
||
|
|
||
|
#[test]
|
||
|
fn test_world() {
|
||
|
let client = Client::new(rocket()).expect("valid rocket instance");
|
||
|
let mut response = client.get("/world").dispatch();
|
||
|
|
||
|
assert_eq!(response.status(), Status::Ok);
|
||
|
assert_eq!(response.body_string(), Some("Hello, world!".into()));
|
||
|
}
|
||
|
|
||
|
#[test]
|
||
|
fn test_hello() {
|
||
|
let client = Client::new(rocket()).expect("valid rocket instance");
|
||
|
let mut response = client.get("/thisisaname").dispatch();
|
||
|
|
||
|
assert_eq!(response.status(), Status::Ok);
|
||
|
assert_eq!(response.body_string(), Some("Hello, thisisaname".into()));
|
||
|
}
|