use rocket::{get, routes, Build, Rocket}; #[get("/")] fn index() -> &'static str { "Hello, world!" } pub fn start() -> Rocket { rocket::build().mount("/", routes![index]) } #[cfg(test)] mod test { use super::start; use rocket::http::Status; use rocket::local::blocking::Client; use rocket::uri; #[test] fn hello_world() { let client = Client::tracked(start()).expect("valid rocket instance"); let response = client.get(uri!(super::index)).dispatch(); assert_eq!(response.status(), Status::Ok); assert_eq!(response.into_string(), Some("Hello, world!".into())); } }