Compare commits
2 Commits
6e0dfabcff
...
4eb0a6360f
| Author | SHA1 | Date | |
|---|---|---|---|
| 4eb0a6360f | |||
| 040b9148de |
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user