test: report failures as got/want and use subtests for tables

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 00:18:02 +01:00
1 parent d20225982a
commit b6843330a8
8 files changed
+184 -175

No files matched your search

+7 -6
View File
@@ -7,18 +7,19 @@ import (
)
func TestFailoverOptionsTakesMasterAuthFromURL(t *testing.T) {
const url = "rediss://app:masterpw@ignored:6379/3"
s := config.Sentinel{Master: "mymaster", Addrs: []string{"s1:26379", "s2:26379"}, Password: "sentinelpw"}
fo, err := failoverOptions("rediss://app:masterpw@ignored:6379/3", s)
fo, err := failoverOptions(url, s)
if err != nil {
t.Fatal(err)
t.Fatalf("failoverOptions(%q) failed: %v", url, err)
}
if fo.Password != "masterpw" || fo.Username != "app" || fo.DB != 3 {
t.Fatalf("master auth not applied: %+v", fo)
if fo.Username != "app" || fo.Password != "masterpw" || fo.DB != 3 {
t.Errorf("failoverOptions(%q) master auth = %q/%q db %d, want app/masterpw db 3", url, fo.Username, fo.Password, fo.DB)
}
if fo.SentinelPassword != "sentinelpw" || len(fo.SentinelAddrs) != 2 {
t.Fatalf("sentinel settings lost: %+v", fo)
t.Errorf("failoverOptions(%q) sentinel = %q %v, want sentinelpw with 2 addrs", url, fo.SentinelPassword, fo.SentinelAddrs)
}
if fo.TLSConfig == nil {
t.Fatal("rediss scheme must enable TLS")
t.Errorf("failoverOptions(%q).TLSConfig = nil, want TLS for rediss scheme", url)
}
}