@@ -151,7 +151,7 @@ var _ = Describe("Redis client", func() {
151151 Eventually (func () map [string ]int {
152152 return redisServer .PubSubNumSub (SyncChannelName )
153153 }).Should (HaveLen (1 ))
154- }, SpecTimeout (time .Second * 6 ))
154+ }, SpecTimeout (time .Second * 3 ))
155155 })
156156 })
157157
@@ -225,7 +225,7 @@ var _ = Describe("Redis client", func() {
225225 Eventually (func () chan * CacheMessage {
226226 return redisClient .CacheChannel
227227 }).Should (HaveLen (lenE + 1 ))
228- }, SpecTimeout (time .Second * 6 ))
228+ }, SpecTimeout (time .Second * 3 ))
229229 })
230230 When ("wrong data is received" , func () {
231231 It ("should not propagate the message over the channel if data is wrong" , func (ctx context.Context ) {
@@ -258,7 +258,7 @@ var _ = Describe("Redis client", func() {
258258 Eventually (func () chan * CacheMessage {
259259 return redisClient .CacheChannel
260260 }).Should (HaveLen (lenC ))
261- }, SpecTimeout (time .Second * 6 ))
261+ }, SpecTimeout (time .Second * 3 ))
262262 It ("should not propagate the message over the channel if type is wrong" , func (ctx context.Context ) {
263263 redisClient , err = New (ctx , redisConfig )
264264 Expect (err ).Should (Succeed ())
@@ -282,16 +282,15 @@ var _ = Describe("Redis client", func() {
282282 rec := redisServer .Publish (SyncChannelName , string (binMsg ))
283283 Expect (rec ).Should (Equal (1 ))
284284
285- time .Sleep (2 * time .Second )
285+ // Use Consistently to verify channels don't receive invalid messages
286+ Consistently (func () int {
287+ return len (redisClient .EnabledChannel )
288+ }, "200ms" , "50ms" ).Should (Equal (lenE ))
286289
287- Eventually (func () chan * EnabledMessage {
288- return redisClient .EnabledChannel
289- }).Should (HaveLen (lenE ))
290-
291- Eventually (func () chan * CacheMessage {
292- return redisClient .CacheChannel
293- }).Should (HaveLen (lenC ))
294- }, SpecTimeout (time .Second * 6 ))
290+ Consistently (func () int {
291+ return len (redisClient .CacheChannel )
292+ }, "200ms" , "50ms" ).Should (Equal (lenC ))
293+ }, SpecTimeout (time .Second * 3 ))
295294 })
296295 })
297296
0 commit comments