mirror of
https://github.com/redis/go-redis.git
synced 2025-07-28 06:42:00 +03:00
@ -338,3 +338,26 @@ var _ = Describe("Client timeout", func() {
|
||||
testTimeout()
|
||||
})
|
||||
})
|
||||
|
||||
var _ = Describe("Client OnConnect", func() {
|
||||
var client *redis.Client
|
||||
|
||||
BeforeEach(func() {
|
||||
opt := redisOptions()
|
||||
opt.OnConnect = func(cn *redis.Conn) error {
|
||||
return cn.ClientSetName("on_connect").Err()
|
||||
}
|
||||
|
||||
client = redis.NewClient(opt)
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
Expect(client.Close()).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
It("calls OnConnect", func() {
|
||||
name, err := client.ClientGetName().Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(name).To(Equal("on_connect"))
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user