fej/src/hello/tests.rs

25 lines
698 B
Rust

use rocket::http::Status;
use rocket::local::Client;
fn rocket() -> rocket::Rocket {
rocket::ignite().mount("/", super::routes())
}
#[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()));
}