Files
stalwart-migrator/internal/preflight/cluster_test.go
T
jcoffey-dev 719a945d64 Initial commit: stalwart-migrator design and scaffolding
In-place upgrade tool for Stalwart Mail Server (0.15.5 -> latest) with
checkpointed rollback and post-migration validation. Design stage; see
ARCHITECTURE.md.
2026-08-22 18:17:17 -07:00

35 lines
860 B
Go

package preflight
import (
"os"
"path/filepath"
"testing"
)
func TestLooksClustered(t *testing.T) {
cases := []struct {
name string
content string
want bool
}{
{"no-cluster", "[server]\nhostname = \"mail.example.com\"\n", false},
{"has-cluster-section", "[cluster]\nnode-id = 1\npeers = [\"10.0.0.2\"]\n", true},
{"cluster-mentioned-in-key", "[server]\ncluster-coordinator = \"redis://localhost\"\n", true},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
path := filepath.Join(t.TempDir(), "config.toml")
if err := os.WriteFile(path, []byte(tc.content), 0o644); err != nil {
t.Fatal(err)
}
got, err := LooksClustered(path)
if err != nil {
t.Fatalf("LooksClustered: %v", err)
}
if got != tc.want {
t.Errorf("LooksClustered(%s) = %v, want %v", tc.name, got, tc.want)
}
})
}
}