From 4307ce45fc5200dc83856d542b400b8d19f0a2f4 Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Thu, 23 Jan 2025 00:03:49 +0800 Subject: [PATCH] chore: add redis test (#4593) --- core/stores/redis/redis.go | 13 ++++++------- core/stores/redis/redis_test.go | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/core/stores/redis/redis.go b/core/stores/redis/redis.go index 2d486227..f7c18a25 100644 --- a/core/stores/redis/redis.go +++ b/core/stores/redis/redis.go @@ -2409,10 +2409,10 @@ func SetSlowThreshold(threshold time.Duration) { slowThreshold.Set(threshold) } -// WithPass customizes the given Redis with given password. -func WithUser(user string) Option { +// WithHook customizes the given Redis with given durationHook. +func WithHook(hook Hook) Option { return func(r *Redis) { - r.User = user + r.hooks = append(r.hooks, hook) } } @@ -2430,11 +2430,10 @@ func WithTLS() Option { } } -// WithHook customizes the given Redis with given durationHook, only for private use now, -// maybe expose later. -func WithHook(hook Hook) Option { +// WithUser customizes the given Redis with given username. +func WithUser(user string) Option { return func(r *Redis) { - r.hooks = append(r.hooks, hook) + r.User = user } } diff --git a/core/stores/redis/redis_test.go b/core/stores/redis/redis_test.go index f609b6ab..062e344c 100644 --- a/core/stores/redis/redis_test.go +++ b/core/stores/redis/redis_test.go @@ -1996,9 +1996,9 @@ func TestSetSlowThreshold(t *testing.T) { assert.Equal(t, time.Second, slowThreshold.Load()) } -func TestRedis_WithPass(t *testing.T) { +func TestRedis_WithUserPass(t *testing.T) { runOnRedis(t, func(client *Redis) { - err := newRedis(client.Addr, WithPass("any")).Ping() + err := newRedis(client.Addr, WithUser("any"), WithPass("any")).Ping() assert.NotNil(t, err) }) }