23 lines
598 B
Go
23 lines
598 B
Go
package health
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"errors"
|
||
|
|
"testing"
|
||
|
|
"time"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestReadyReportsDependencyFailure(t *testing.T) {
|
||
|
|
checker := NewChecker(time.Second, map[string]CheckFunc{
|
||
|
|
"database": func(context.Context) error { return nil },
|
||
|
|
"redis": func(context.Context) error { return errors.New("unavailable") },
|
||
|
|
})
|
||
|
|
result := checker.Ready(context.Background())
|
||
|
|
if result.Status != "not_ready" {
|
||
|
|
t.Fatalf("status = %s, want not_ready", result.Status)
|
||
|
|
}
|
||
|
|
if result.Checks["database"] != "up" || result.Checks["redis"] != "down" {
|
||
|
|
t.Fatalf("unexpected checks: %#v", result.Checks)
|
||
|
|
}
|
||
|
|
}
|