#![feature(proc_macro_hygiene)] #[macro_use] extern crate rocket; #[get("/")] fn hello() -> &'static str { "Hello, world!" } fn rocket() -> rocket::Rocket { rocket::ignite().mount("/", routes![hello]) } fn main() { rocket().launch(); } #[cfg(test)] mod test { use super::rocket; use rocket::local::Client; use rocket::http::Status; #[rocket::async_test] async fn test_hello() { let client = Client::new(rocket()).unwrap(); let mut response = client.get("/").dispatch().await; assert_eq!(response.status(), Status::Ok); assert_eq!(response.body_string().await, Some("Hello, world!".into())); } }