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.

test: Add permanent failure test for ClusterClient.GetNodes

rcourtman22d9e2795cf7
diff --git a/pkg/proxmox/cluster_client_test.go b/pkg/proxmox/cluster_client_test.go
index 88936d3129..62084f0454 100644
--- a/pkg/proxmox/cluster_client_test.go
+++ b/pkg/proxmox/cluster_client_test.go
@@ -327,3 +327,34 @@ func TestIsAuthError(t *testing.T) {
})
}
}
+
+func TestClusterClient_GetNodes_PermanentFailure(t *testing.T) {
+ // Server that always returns auth error - not retryable
+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusUnauthorized)
+ fmt.Fprint(w, `{"data":null,"errors":{"username":"invalid credentials"}}`)
+ }))
+ defer server.Close()
+
+ cfg := ClientConfig{
+ Host: server.URL,
+ TokenName: "invalid@pve!token",
+ TokenValue: "badvalue",
+ VerifySSL: false,
+ Timeout: 2 * time.Second,
+ }
+
+ cc := NewClusterClient("test-cluster", cfg, []string{server.URL})
+
+ ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
+ defer cancel()
+
+ nodes, err := cc.GetNodes(ctx)
+ if err == nil {
+ t.Fatal("expected GetNodes to fail with auth error, got nil")
+ }
+ if nodes != nil {
+ t.Errorf("expected nil nodes on error, got %v", nodes)
+ }
+}