Use live MQTT readiness for server health checks
Test and deploy MQTT backend / test (push) Successful in 1m44s
Test and deploy MQTT backend / deploy (push) Successful in 14s

This commit is contained in:
2026-10-08 14:51:32 +03:30
parent 71ef622b4f
commit 9a32f634d4
5 changed files with 35 additions and 2 deletions
+16
View File
@@ -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)
}
}
}