Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
26 lines
779 B
Go
26 lines
779 B
Go
package config
|
|
|
|
import "testing"
|
|
|
|
func TestCommonValidateRedisModes(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
modify func(*Common)
|
|
wantErr bool
|
|
}{
|
|
{"standalone", func(c *Common) { c.RedisURL = "redis://r" }, false},
|
|
{"no redis", func(*Common) {}, true},
|
|
{"sentinel", func(c *Common) { c.RedisSentinel = Sentinel{Master: "m", Addrs: []string{"s:26379"}} }, false},
|
|
{"sentinel without addrs", func(c *Common) { c.RedisSentinel = Sentinel{Master: "m"} }, true},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
c := Common{Edition: EditionSelfHosted, DatabaseURL: "postgres://x"}
|
|
tt.modify(&c)
|
|
if err := c.Validate(); (err != nil) != tt.wantErr {
|
|
t.Errorf("Validate() = %v, want error: %t", err, tt.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|