From a1b141d31a0b0a12890937884b3cff070bca8632 Mon Sep 17 00:00:00 2001 From: kevin Date: Sat, 10 Oct 2020 18:22:25 +0800 Subject: [PATCH] make tests faster --- core/stores/cache/cachenode_test.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/core/stores/cache/cachenode_test.go b/core/stores/cache/cachenode_test.go index 86acdb3e..b6c1fad5 100644 --- a/core/stores/cache/cachenode_test.go +++ b/core/stores/cache/cachenode_test.go @@ -11,6 +11,7 @@ import ( "github.com/alicebob/miniredis" "github.com/stretchr/testify/assert" + "github.com/tal-tech/go-zero/core/lang" "github.com/tal-tech/go-zero/core/logx" "github.com/tal-tech/go-zero/core/mathx" "github.com/tal-tech/go-zero/core/stat" @@ -181,10 +182,18 @@ func TestCacheNode_String(t *testing.T) { func TestCacheValueWithBigInt(t *testing.T) { s, err := miniredis.Run() - if err != nil { - t.Error(err) - } - defer s.Close() + assert.Nil(t, err) + defer func() { + ch := make(chan lang.PlaceholderType) + go func() { + s.Close() + close(ch) + }() + select { + case <-ch: + case <-time.After(time.Second): + } + }() cn := cacheNode{ rds: redis.NewRedis(s.Addr(), redis.NodeType),