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 recovery token load read error
rcourtman588665a86fb5
diff --git a/internal/api/recovery_tokens_test.go b/internal/api/recovery_tokens_test.goindex b41f131b8b..52cf37a7b0 100644--- a/internal/api/recovery_tokens_test.go+++ b/internal/api/recovery_tokens_test.go@@ -574,6 +574,33 @@ func TestRecoveryTokenStore_Load_InvalidJSON(t *testing.T) {}}+func TestRecoveryTokenStore_Load_ReadError(t *testing.T) {+ tmpDir := t.TempDir()++ // Create a directory where the tokens file should be - reading it will fail+ tokensPath := filepath.Join(tmpDir, "recovery_tokens.json")+ if err := os.Mkdir(tokensPath, 0755); err != nil {+ t.Fatalf("failed to create directory: %v", err)+ }++ store := &RecoveryTokenStore{+ tokens: make(map[string]*RecoveryToken),+ dataPath: tmpDir,+ stopCleanup: make(chan struct{}),+ }++ // Should not panic and should log error+ store.load()++ store.mu.RLock()+ count := len(store.tokens)+ store.mu.RUnlock()++ if count != 0 {+ t.Errorf("store should be empty after read error, got %d tokens", count)+ }+}+func TestRecoveryTokenStore_StopCleanup(t *testing.T) {store := newTestRecoveryStore(t)