Skip to content

Commit

Permalink
chore: add redis test
Browse files Browse the repository at this point in the history
  • Loading branch information
kevwan committed Jan 22, 2025
1 parent 37b54d1 commit 8df4015
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
13 changes: 6 additions & 7 deletions core/stores/redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand All @@ -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
}
}

Expand Down
4 changes: 2 additions & 2 deletions core/stores/redis/redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
Expand Down

0 comments on commit 8df4015

Please sign in to comment.