Files
upstream-centrifugo/internal/confighelpers/redis_test.go
upstream-mirror b352a9a30d
Some checks failed
test / Lint (push) Failing after 3s
test / Test with Go 1.26.8 (push) Failing after 2s
snapshot of https://github.com/centrifugal/centrifugo.git (master, 2026-09-16; blobs > 131072B omitted)
2026-09-16 01:17:21 +05:00

47 lines
1.0 KiB
Go

package confighelpers
import "testing"
func TestMergeModes(t *testing.T) {
tests := []struct {
input []string
expected string
}{
{
input: []string{"cluster", "cluster", "standalone", "sentinel", "sentinel", "cluster"},
expected: "cluster-x2,standalone,sentinel-x2,cluster",
},
{
input: []string{"standalone"},
expected: "standalone",
},
{
input: []string{"sentinel", "sentinel", "sentinel"},
expected: "sentinel-x3",
},
{
input: []string{"cluster", "standalone", "sentinel"},
expected: "cluster,standalone,sentinel",
},
{
input: []string{},
expected: "",
},
{
input: []string{"a", "a", "a", "b", "b", "c", "a"},
expected: "a-x3,b-x2,c,a",
},
{
input: []string{"a", "b", "b", "b", "c", "c", "d", "d", "d", "d"},
expected: "a,b-x3,c-x2,d-x4",
},
}
for _, test := range tests {
got := mergeModes(test.input)
if got != test.expected {
t.Errorf("mergeModes(%v) = %q; want %q", test.input, got, test.expected)
}
}
}