Files
upstream-centrifugo/internal/redisshard/init_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

51 lines
1.2 KiB
Go

package redisshard
import (
"testing"
"github.com/centrifugal/centrifugo/v6/internal/configtypes"
"github.com/stretchr/testify/require"
)
func TestGetRedisShardConfigsCommonSettings(t *testing.T) {
t.Parallel()
common := configtypes.Redis{
DB: 2,
User: "user",
Password: "pass",
ClientName: "centrifugo-consumer",
ForceResp2: true,
}
standalone := common
standalone.Address = []string{"redis://127.0.0.1:6379"}
cluster := common
cluster.ClusterAddress = []string{"127.0.0.1:7000,127.0.0.1:7001"}
sentinel := common
sentinel.SentinelAddress = []string{"127.0.0.1:26379"}
sentinel.SentinelMasterName = "mymaster"
for name, redisConf := range map[string]configtypes.Redis{
"standalone": standalone,
"cluster": cluster,
"sentinel": sentinel,
} {
t.Run(name, func(t *testing.T) {
t.Parallel()
shardConfigs, err := getRedisShardConfigs(redisConf)
require.NoError(t, err)
require.Len(t, shardConfigs, 1)
conf := shardConfigs[0]
require.Equal(t, 2, conf.DB)
require.Equal(t, "user", conf.User)
require.Equal(t, "pass", conf.Password)
require.Equal(t, "centrifugo-consumer", conf.ClientName)
require.True(t, conf.ForceRESP2)
})
}
}