Compare commits

...

2 Commits

2 changed files with 14 additions and 4 deletions

View File

@@ -35,12 +35,17 @@ type OverallResult struct {
func determineOverallStatus(results map[string]Result) Status {
hasUnhealthy := false
hasSMTPUnhealthy := false
hasDegraded := false
for _, result := range results {
for name, result := range results {
switch result.Status {
case StatusUnhealthy:
if name == "smtp" {
hasSMTPUnhealthy = true
} else {
hasUnhealthy = true
}
case StatusDegraded:
hasDegraded = true
}
@@ -49,7 +54,7 @@ func determineOverallStatus(results map[string]Result) Status {
if hasUnhealthy {
return StatusUnhealthy
}
if hasDegraded {
if hasDegraded || hasSMTPUnhealthy {
return StatusDegraded
}
return StatusHealthy

View File

@@ -57,10 +57,15 @@ func TestDetermineOverallStatus(t *testing.T) {
results: map[string]Result{"db": {Status: StatusUnhealthy}, "smtp": {Status: StatusHealthy}},
expected: StatusUnhealthy,
},
{
name: "smtp unhealthy downgrades overall to degraded",
results: map[string]Result{"db": {Status: StatusHealthy}, "smtp": {Status: StatusUnhealthy}},
expected: StatusDegraded,
},
{
name: "mixed degraded and unhealthy",
results: map[string]Result{"db": {Status: StatusDegraded}, "smtp": {Status: StatusUnhealthy}},
expected: StatusUnhealthy,
expected: StatusDegraded,
},
{
name: "empty results",