mirror of
https://github.com/redis/go-redis.git
synced 2025-07-28 06:42:00 +03:00
Support for CLIENT SETINFO (#2659)
* feat: merge master * feat: revert ring.go * feat: add ClientSetInfo command * fix: test and cmd: * fix: test and cmd * fix: test and cmd * fix: test and cmd * feat: redesigning the API * fix: panic test * fix: panic test --------- Co-authored-by: Anuragkillswitch <70265851+Anuragkillswitch@users.noreply.github.com> Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
017466b6cc
commit
3b0d10b4ed
@ -231,6 +231,57 @@ var _ = Describe("Commands", func() {
|
||||
Expect(get.Val()).To(Equal("theclientname"))
|
||||
})
|
||||
|
||||
It("should ClientSetInfo", func() {
|
||||
|
||||
pipe := client.Pipeline()
|
||||
|
||||
// Test setting the libName
|
||||
libName := "go-redis"
|
||||
libInfo := redis.LibraryInfo{LibName: &libName}
|
||||
setInfo := pipe.ClientSetInfo(ctx, libInfo)
|
||||
_, err := pipe.Exec(ctx)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(setInfo.Err()).NotTo(HaveOccurred())
|
||||
Expect(setInfo.Val()).To(Equal("OK"))
|
||||
|
||||
// Test setting the libVer
|
||||
libVer := "vX.x"
|
||||
libInfo = redis.LibraryInfo{LibVer: &libVer}
|
||||
setInfo = pipe.ClientSetInfo(ctx, libInfo)
|
||||
_, err = pipe.Exec(ctx)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(setInfo.Err()).NotTo(HaveOccurred())
|
||||
Expect(setInfo.Val()).To(Equal("OK"))
|
||||
|
||||
// Test setting both fields, expect a panic
|
||||
libInfo = redis.LibraryInfo{LibName: &libName, LibVer: &libVer}
|
||||
|
||||
Expect(func() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
err := r.(error)
|
||||
Expect(err).To(MatchError("both LibName and LibVer cannot be set at the same time"))
|
||||
}
|
||||
}()
|
||||
pipe.ClientSetInfo(ctx, libInfo)
|
||||
}).To(Panic())
|
||||
|
||||
// Test setting neither field, expect a panic
|
||||
libInfo = redis.LibraryInfo{}
|
||||
|
||||
Expect(func() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
err := r.(error)
|
||||
Expect(err).To(MatchError("at least one of LibName and LibVer should be set"))
|
||||
}
|
||||
}()
|
||||
pipe.ClientSetInfo(ctx, libInfo)
|
||||
}).To(Panic())
|
||||
})
|
||||
|
||||
It("should ConfigGet", func() {
|
||||
val, err := client.ConfigGet(ctx, "*").Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
Reference in New Issue
Block a user