Files
uptimesebi/internal/config/config_test.go
T

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)
}
})
}
}