Use live MQTT readiness for server health checks
This commit is contained in:
@@ -162,3 +162,19 @@ func TestReportedScenariosDoNotClaimHardwareCompatibility(t *testing.T) {
|
||||
t.Fatal("scenario aliases retained history")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHealthUsesCurrentMQTTReadiness(t *testing.T) {
|
||||
v := testViewer()
|
||||
ready := false
|
||||
v.SetReadiness(func() bool { return ready })
|
||||
for _, want := range []int{503, 200, 503} {
|
||||
ready = want == 200
|
||||
// No connection event retained: current readiness must still work.
|
||||
r := httptest.NewRequest("GET", "http://127.0.0.1:8080/healthz", nil)
|
||||
w := httptest.NewRecorder()
|
||||
v.Handler().ServeHTTP(w, r)
|
||||
if w.Code != want {
|
||||
t.Fatalf("health status %d, want %d", w.Code, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user