Skip to content

Commit

Permalink
fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
doylemark committed Aug 27, 2024
1 parent 3f8dd89 commit 0b8000e
Showing 1 changed file with 30 additions and 9 deletions.
39 changes: 30 additions & 9 deletions shared/src/server/health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ mod test {
use super::*;

#[tokio::test]
async fn test_max_of_enum() {
// used in run_ecs_health_check_service to ensure non-success codes have priority
async fn it_returns_errors_over_health_up_responses() {
let max = [
UserProcessHealth::Error("".to_string()),
UserProcessHealth::Response {
Expand All @@ -189,13 +188,11 @@ mod test {
.into_iter()
.max()
.unwrap();
assert!(matches!(
max,
UserProcessHealth::Response {
status_code: 200,
body: None,
}
));
assert!(matches!(max, UserProcessHealth::Error(_)));
}

#[tokio::test]
async fn it_returns_errors_over_unknown() {
let max = [
UserProcessHealth::Unknown("".to_string()),
UserProcessHealth::Unknown("".to_string()),
Expand All @@ -207,4 +204,28 @@ mod test {
.unwrap();
assert!(matches!(max, UserProcessHealth::Error(_)));
}

#[tokio::test]
async fn it_returns_unhealthy_up_responses_over_errors() {
let max = [
UserProcessHealth::Unknown("".to_string()),
UserProcessHealth::Unknown("".to_string()),
UserProcessHealth::Error("".to_string()),
UserProcessHealth::Response {
status_code: 500,
body: None,
},
UserProcessHealth::Unknown("".to_string()),
]
.into_iter()
.max()
.unwrap();
assert!(matches!(
max,
UserProcessHealth::Response {
status_code: 500,
body: None,
}
));
}
}

0 comments on commit 0b8000e

Please sign in to comment.