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 edge case tests for ClearActiveAlerts and sanitizeAlertKey
rcourtmanb1f5dac4fc56
diff --git a/internal/alerts/alerts_test.go b/internal/alerts/alerts_test.goindex 7090eceb08..7756cde1fa 100644--- a/internal/alerts/alerts_test.go+++ b/internal/alerts/alerts_test.go@@ -4121,3 +4121,24 @@ func TestUnacknowledgeAlertSuccess(t *testing.T) {t.Error("expected ackState entry to be deleted")}}++func TestClearActiveAlertsEmptyMaps(t *testing.T) {+ t.Parallel()+ m := NewManager()++ // Ensure maps are empty initially+ if len(m.activeAlerts) != 0 {+ t.Fatalf("expected activeAlerts to be empty, got %d", len(m.activeAlerts))+ }+ if len(m.pendingAlerts) != 0 {+ t.Fatalf("expected pendingAlerts to be empty, got %d", len(m.pendingAlerts))+ }++ // Call ClearActiveAlerts on empty manager - should return early without panic+ m.ClearActiveAlerts()++ // Verify maps are still empty (function returned early)+ if len(m.activeAlerts) != 0 {+ t.Errorf("expected activeAlerts to remain empty, got %d", len(m.activeAlerts))+ }+}diff --git a/internal/alerts/utility_test.go b/internal/alerts/utility_test.goindex 4c554d29cc..1895ee8956 100644--- a/internal/alerts/utility_test.go+++ b/internal/alerts/utility_test.go@@ -96,6 +96,11 @@ func TestSanitizeAlertKey(t *testing.T) {},// Edge cases+ {+ name: "only slashes and backslashes becomes root",+ input: "//\\\\",+ want: "root",+ },{name: "only special chars becomes disk",input: "@#$%",