We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2031fd9 commit c15d441Copy full SHA for c15d441
src/main.rs
@@ -2,11 +2,27 @@
2
extern crate rocket;
3
4
#[get("/")]
5
-fn index() -> &'static str {
+fn hello() -> &'static str {
6
"Hello, world!"
7
}
8
9
#[launch]
10
fn rocket() -> _ {
11
- rocket::build().mount("/", routes![index])
+ rocket::build().mount("/", routes![hello])
12
+}
13
+
14
+#[cfg(test)]
15
+mod test {
16
+ use super::rocket;
17
+ use rocket::local::blocking::Client;
18
+ use rocket::http::Status;
19
20
+ #[test]
21
+ fn test_hello() {
22
+ let client = Client::tracked(rocket()).expect("valid rocket instance");
23
+ let response = client.get(uri!(super::hello)).dispatch();
24
25
+ assert_eq!(response.status(), Status::Ok);
26
+ assert_eq!(response.into_string().unwrap(), "Hello, world!");
27
+ }
28
0 commit comments