Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
26 lines
941 B
Go
26 lines
941 B
Go
package platform
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.zb-server.de/ZB-Server/uptimesebi/internal/config"
|
|
)
|
|
|
|
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(url, s)
|
|
if err != nil {
|
|
t.Fatalf("failoverOptions(%q) failed: %v", url, err)
|
|
}
|
|
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.Errorf("failoverOptions(%q) sentinel = %q %v, want sentinelpw with 2 addrs", url, fo.SentinelPassword, fo.SentinelAddrs)
|
|
}
|
|
if fo.TLSConfig == nil {
|
|
t.Errorf("failoverOptions(%q).TLSConfig = nil, want TLS for rediss scheme", url)
|
|
}
|
|
}
|