1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

feat(options): panic when options are nil (#3363)

Client creation should panic when options are nil.
This commit is contained in:
Nedyalko Dyakov
2025-04-30 09:33:40 +03:00
committed by GitHub
parent 683f644ec2
commit d54e848055
6 changed files with 75 additions and 0 deletions

View File

@ -727,3 +727,54 @@ var _ = Describe("Dialer connection timeouts", func() {
Expect(time.Since(start)).To(BeNumerically("<", 2*dialSimulatedDelay))
})
})
var _ = Describe("Client creation", func() {
Context("simple client with nil options", func() {
It("panics", func() {
Expect(func() {
redis.NewClient(nil)
}).To(Panic())
})
})
Context("cluster client with nil options", func() {
It("panics", func() {
Expect(func() {
redis.NewClusterClient(nil)
}).To(Panic())
})
})
Context("ring client with nil options", func() {
It("panics", func() {
Expect(func() {
redis.NewRing(nil)
}).To(Panic())
})
})
Context("universal client with nil options", func() {
It("panics", func() {
Expect(func() {
redis.NewUniversalClient(nil)
}).To(Panic())
})
})
Context("failover client with nil options", func() {
It("panics", func() {
Expect(func() {
redis.NewFailoverClient(nil)
}).To(Panic())
})
})
Context("failover cluster client with nil options", func() {
It("panics", func() {
Expect(func() {
redis.NewFailoverClusterClient(nil)
}).To(Panic())
})
})
Context("sentinel client with nil options", func() {
It("panics", func() {
Expect(func() {
redis.NewSentinelClient(nil)
}).To(Panic())
})
})
})