mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 09:00:20 +08:00
chore: add redis test (#4593)
This commit is contained in:
parent
37b54d1fc7
commit
4307ce45fc
@ -2409,10 +2409,10 @@ func SetSlowThreshold(threshold time.Duration) {
|
|||||||
slowThreshold.Set(threshold)
|
slowThreshold.Set(threshold)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithPass customizes the given Redis with given password.
|
// WithHook customizes the given Redis with given durationHook.
|
||||||
func WithUser(user string) Option {
|
func WithHook(hook Hook) Option {
|
||||||
return func(r *Redis) {
|
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,
|
// WithUser customizes the given Redis with given username.
|
||||||
// maybe expose later.
|
func WithUser(user string) Option {
|
||||||
func WithHook(hook Hook) Option {
|
|
||||||
return func(r *Redis) {
|
return func(r *Redis) {
|
||||||
r.hooks = append(r.hooks, hook)
|
r.User = user
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1996,9 +1996,9 @@ func TestSetSlowThreshold(t *testing.T) {
|
|||||||
assert.Equal(t, time.Second, slowThreshold.Load())
|
assert.Equal(t, time.Second, slowThreshold.Load())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRedis_WithPass(t *testing.T) {
|
func TestRedis_WithUserPass(t *testing.T) {
|
||||||
runOnRedis(t, func(client *Redis) {
|
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)
|
assert.NotNil(t, err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user