Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

ADA changes (auto-committed by cron safety check)

rcourtman6c88f7940455
diff --git a/internal/api/config_handlers_host_test.go b/internal/api/config_handlers_host_test.go
index 2575afbd9c..2ac1113905 100644
--- a/internal/api/config_handlers_host_test.go
+++ b/internal/api/config_handlers_host_test.go
@@ -385,3 +385,39 @@ func TestNormalizeNodeHost(t *testing.T) {
})
}
}
+
+func TestGenerateNodeID(t *testing.T) {
+ tests := []struct {
+ name string
+ nodeType string
+ index int
+ want string
+ }{
+ // Standard node types
+ {"pve node index 0", "pve", 0, "pve-0"},
+ {"pve node index 1", "pve", 1, "pve-1"},
+ {"pbs node index 0", "pbs", 0, "pbs-0"},
+ {"pmg node index 5", "pmg", 5, "pmg-5"},
+ {"docker node index 2", "docker", 2, "docker-2"},
+
+ // Edge cases
+ {"empty node type", "", 0, "-0"},
+ {"negative index", "pve", -1, "pve--1"},
+ {"large index", "pve", 999, "pve-999"},
+ {"very large index", "pve", 2147483647, "pve-2147483647"},
+
+ // Custom/unknown node types
+ {"custom type", "custom-type", 3, "custom-type-3"},
+ {"type with spaces", "my node", 1, "my node-1"},
+ {"type with special chars", "node_v2", 0, "node_v2-0"},
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ got := generateNodeID(tt.nodeType, tt.index)
+ if got != tt.want {
+ t.Errorf("generateNodeID(%q, %d) = %q, want %q", tt.nodeType, tt.index, got, tt.want)
+ }
+ })
+ }
+}