Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
test: Add panic recovery test for ErrorHandler
rcourtman970e6c4d7433
diff --git a/internal/api/middleware_test.go b/internal/api/middleware_test.goindex 410eceeb02..ea25bb54ed 100644--- a/internal/api/middleware_test.go+++ b/internal/api/middleware_test.go@@ -460,3 +460,20 @@ func TestErrorHandler_EmptyPath(t *testing.T) {t.Errorf("expected empty path to be normalized to '/', got %q", capturedPath)}}++func TestErrorHandler_PanicRecovery(t *testing.T) {+ // Test that panics are recovered and return 500+ handler := ErrorHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ panic("test panic")+ }))++ req := httptest.NewRequest(http.MethodGet, "/test", nil)+ rec := httptest.NewRecorder()++ // Should not panic - ErrorHandler recovers it+ handler.ServeHTTP(rec, req)++ if rec.Code != http.StatusInternalServerError {+ t.Errorf("expected 500 after panic recovery, got %d", rec.Code)+ }+}