package config import "testing" func TestStorageValidateRedisModes(t *testing.T) { tests := []struct { name string modify func(*Storage) wantErr bool }{ {"standalone", func(c *Storage) { c.RedisURL = "redis://r" }, false}, {"no redis", func(*Storage) {}, true}, {"sentinel", func(c *Storage) { c.RedisSentinel = Sentinel{Master: "m", Addrs: []string{"s:26379"}} }, false}, {"sentinel without addrs", func(c *Storage) { c.RedisSentinel = Sentinel{Master: "m"} }, true}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { c := Storage{DatabaseURL: "postgres://x"} tt.modify(&c) if err := c.Validate(); (err != nil) != tt.wantErr { t.Errorf("Validate() = %v, want error: %t", err, tt.wantErr) } }) } }