Skip to content

Commit

Permalink
Merge pull request #11 from Bibimbap-Team/2-implement-feature-for-hea…
Browse files Browse the repository at this point in the history
…lth-check

Implement feature for health check
  • Loading branch information
utilForever authored Jul 26, 2024
2 parents 093d76c + 722befb commit cfde571
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
#[macro_use]
extern crate rocket;

#[get("/")]
fn hello() -> &'static str {
"Hello, world!"
#[get("/health_check")]
fn health_check() {
()
}

#[launch]
fn rocket() -> _ {
rocket::build().mount("/", routes![hello])
rocket::build().mount("/", routes![health_check])
}

#[cfg(test)]
mod test {
use super::rocket;
use rocket::http::Status;
use rocket::local::blocking::Client;
use std::io::Read;

#[test]
fn test_hello() {
let client = Client::tracked(rocket()).expect("valid rocket instance");
let response = client.get(uri!(super::hello)).dispatch();
fn health_check_works() {
let client = Client::tracked(rocket()).expect("Failed to create client");
let response = client.get(uri!(super::health_check)).dispatch();

assert_eq!(response.status(), Status::Ok);
assert_eq!(response.into_string().unwrap(), "Hello, world!");
assert_eq!(response.bytes().count(), 0);
}
}

0 comments on commit cfde571

Please sign in to comment.