Files
uptimesebi/internal/config/config_test.go
T

26 lines
700 B
Go

package config
import "testing"
func TestValidateRedisModes(t *testing.T) {
base := Common{Edition: EditionSelfHosted, DatabaseURL: "postgres://x"}
cases := []struct {
name string
mod func(*Common)
ok bool
}{
{"standalone", func(c *Common) { c.RedisURL = "redis://r" }, true},
{"nothing", func(c *Common) {}, false},
{"sentinel", func(c *Common) { c.RedisSentinel = Sentinel{Master: "m", Addrs: []string{"s:26379"}} }, true},
{"sentinel without addrs", func(c *Common) { c.RedisSentinel = Sentinel{Master: "m"} }, false},
}
for _, tc := range cases {
c := base
tc.mod(&c)
if err := c.Validate(); (err == nil) != tc.ok {
t.Errorf("%s: err=%v", tc.name, err)
}
}
}