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 for clearBootstrapToken remove failure
rcourtman41a7bdf7ffc2
diff --git a/internal/api/bootstrap_token_test.go b/internal/api/bootstrap_token_test.goindex 77976ea274..cdfefedf4f 100644--- a/internal/api/bootstrap_token_test.go+++ b/internal/api/bootstrap_token_test.go@@ -519,4 +519,28 @@ func TestClearBootstrapToken(t *testing.T) {t.Errorf("expected empty bootstrapTokenHash, got %q", r.bootstrapTokenHash)}})++ t.Run("remove failure logs warning but clears fields", func(t *testing.T) {+ // Point to a directory with contents - os.Remove will fail with ENOTEMPTY+ tmpDir := t.TempDir()+ subFile := filepath.Join(tmpDir, "subfile")+ if err := os.WriteFile(subFile, []byte("test"), 0o600); err != nil {+ t.Fatalf("failed to create subfile: %v", err)+ }++ r := &Router{+ bootstrapTokenHash: "somehash",+ bootstrapTokenPath: tmpDir, // Point to directory, not file+ }++ // Should not panic and should clear fields even if remove fails+ r.clearBootstrapToken()++ if r.bootstrapTokenHash != "" {+ t.Errorf("expected empty bootstrapTokenHash, got %q", r.bootstrapTokenHash)+ }+ if r.bootstrapTokenPath != "" {+ t.Errorf("expected empty bootstrapTokenPath, got %q", r.bootstrapTokenPath)+ }+ })}