diff --git a/crates/jstzd/src/task/octez_node.rs b/crates/jstzd/src/task/octez_node.rs index 324ec56c..9f90dfb6 100644 --- a/crates/jstzd/src/task/octez_node.rs +++ b/crates/jstzd/src/task/octez_node.rs @@ -229,18 +229,25 @@ mod tests { } pub async fn get(url: String) -> anyhow::Result { if url.contains("success") { + // Simulating a normal and expected response from the health check endpoint anyhow::Ok(MockBody { res: HashMap::from([("ready".to_owned(), true)]), bad_json: false, }) } else if url.contains("server_error") { + // Simulating the case where the server is not accessible or + // returns a 4xx/5xx code Err(anyhow::anyhow!("server error")) } else if url.contains("json_error") { + // Simulating the case where the health check endpoint response cannot + // be deserialised correctly anyhow::Ok(MockBody { res: HashMap::new(), bad_json: true, }) } else { + // Simulating the case where the health check endpoint does not return the + // expected data and thus the health check method cannot capture the information anyhow::Ok(MockBody { res: HashMap::new(), bad_json: false, @@ -319,6 +326,7 @@ mod tests { #[tokio::test(flavor = "multi_thread")] async fn health_check_ready() { + // Test if the method identifies a healthy service let f = OctezNode::spawn(OctezNodeConfig::new( "/tmp/binary", "/tmp/something", @@ -335,6 +343,7 @@ mod tests { #[tokio::test(flavor = "multi_thread")] async fn health_check_server_error() { + // Test if the method handles 4xx/5xx errors from the health check endpoint let f = OctezNode::spawn(OctezNodeConfig::new( "/tmp/binary", "/tmp/something", @@ -351,6 +360,7 @@ mod tests { #[tokio::test(flavor = "multi_thread")] async fn health_check_json_error() { + // Test if the method handles bad data deserialisation let f = OctezNode::spawn(OctezNodeConfig::new( "/tmp/binary", "/tmp/something", @@ -370,6 +380,7 @@ mod tests { #[tokio::test(flavor = "multi_thread")] async fn health_check_body_error() { + // Test if the method handles unexpected health check information let f = OctezNode::spawn(OctezNodeConfig::new( "/tmp/binary", "/tmp/something",