fej/src/hello/tests.rs

25 lines
735 B
Rust
Raw Normal View History

2021-03-05 23:34:38 +01:00
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()));
}