Skip to content

Commit 2e5a198

Browse files
committed
test: Implement integration test for a health-check endpoint
1 parent 84e0024 commit 2e5a198

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/main.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,20 @@ fn health_check() {
1010
fn rocket() -> _ {
1111
rocket::build().mount("/", routes![health_check])
1212
}
13+
14+
#[cfg(test)]
15+
mod test {
16+
use super::rocket;
17+
use rocket::http::Status;
18+
use rocket::local::blocking::Client;
19+
use std::io::Read;
20+
21+
#[test]
22+
fn test_hello() {
23+
let client = Client::tracked(rocket()).expect("Failed to create client");
24+
let response = client.get(uri!(super::health_check)).dispatch();
25+
26+
assert_eq!(response.status(), Status::Ok);
27+
assert_eq!(response.bytes().count(), 0);
28+
}
29+
}

0 commit comments

Comments
 (0)