Pulse/internal/config/persistence_fail_test.go

20 lines
551 B
Go

package config
import (
"os"
"path/filepath"
"testing"
)
func TestNewConfigPersistenceFailsWhenEncryptedDataPresentWithoutKey(t *testing.T) {
dir := t.TempDir()
// Simulate existing encrypted data without providing the encryption key.
if err := os.WriteFile(filepath.Join(dir, "nodes.enc"), []byte("ciphertext"), 0600); err != nil {
t.Fatalf("failed to write simulated encrypted file: %v", err)
}
if _, err := newConfigPersistence(dir); err == nil {
t.Fatalf("expected error when initializing persistence without encryption key")
}
}