From 63951b5b27a90738fe251a48305f65954df3fec9 Mon Sep 17 00:00:00 2001 From: Rueian Date: Thu, 20 Jun 2024 21:39:54 +0800 Subject: [PATCH] test: more leak detections Signed-off-by: Rueian --- client_test.go | 4 ++++ cluster_test.go | 1 + message_test.go | 10 +++++++++ pipe_test.go | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ pool_test.go | 1 + rueidis_test.go | 1 + 6 files changed, 76 insertions(+) diff --git a/client_test.go b/client_test.go index b02cedf1..1d7205ad 100644 --- a/client_test.go +++ b/client_test.go @@ -202,6 +202,7 @@ func TestNewSingleClientReplicaOnlyNotSupported(t *testing.T) { } func TestNewSingleClientError(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) v := errors.New("dail err") if _, err := newSingleClient(&ClientOption{InitAddress: []string{""}}, nil, func(dst string, opt *ClientOption) conn { return &mockConn{DialFn: func() error { return v }} @@ -211,6 +212,7 @@ func TestNewSingleClientError(t *testing.T) { } func TestNewSingleClientOverride(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) m1 := &mockConn{} var m2 conn if _, err := newSingleClient(&ClientOption{InitAddress: []string{""}}, m1, func(dst string, opt *ClientOption) conn { @@ -225,6 +227,7 @@ func TestNewSingleClientOverride(t *testing.T) { //gocyclo:ignore func TestSingleClient(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) m := &mockConn{ AddrFn: func() string { return "myaddr" }, } @@ -587,6 +590,7 @@ func TestSingleClient(t *testing.T) { } func TestSingleClientRetry(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) SetupClientRetry(t, func(m *mockConn) Client { c, err := newSingleClient(&ClientOption{InitAddress: []string{""}}, m, func(dst string, opt *ClientOption) conn { return m diff --git a/cluster_test.go b/cluster_test.go index a1255755..12f81b31 100644 --- a/cluster_test.go +++ b/cluster_test.go @@ -4333,6 +4333,7 @@ func TestClusterShardsParsing(t *testing.T) { // https://github.com/redis/rueidis/issues/543 func TestConnectToNonAvailableCluster(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) var wg sync.WaitGroup for i := 0; i < 4; i++ { wg.Add(1) diff --git a/message_test.go b/message_test.go index 446befff..0348aad6 100644 --- a/message_test.go +++ b/message_test.go @@ -1873,6 +1873,9 @@ func TestRedisMessage(t *testing.T) { if ret, _ := (RedisResult{val: RedisMessage{typ: '*', values: []RedisMessage{{string: "0", typ: '+'}, {typ: '_'}}}}).AsScanEntry(); !reflect.DeepEqual(ScanEntry{}, ret) { t.Fatal("AsScanEntry not get value as expected") } + if _, err := (RedisResult{val: RedisMessage{typ: '*', values: []RedisMessage{{string: "0", typ: '+'}}}}).AsScanEntry(); err == nil || !strings.Contains(err.Error(), "a scan response or its length is not at least 2") { + t.Fatal("AsScanEntry not get value as expected") + } }) t.Run("ToMap with non-string key", func(t *testing.T) { @@ -1883,6 +1886,13 @@ func TestRedisMessage(t *testing.T) { if !strings.Contains(err.Error(), "redis message type set is not a RESP3 map") { t.Fatalf("ToMap failed with unexpected error: %v", err) } + _, err = (&RedisMessage{typ: '%', values: []RedisMessage{{typ: ':'}, {typ: ':'}}}).ToMap() + if err == nil { + t.Fatal("ToMap did not fail as expected") + } + if !strings.Contains(err.Error(), "int64 as map key is not supported") { + t.Fatalf("ToMap failed with unexpected error: %v", err) + } }) t.Run("IsCacheHit", func(t *testing.T) { diff --git a/pipe_test.go b/pipe_test.go index 85c4597d..3022d5ff 100644 --- a/pipe_test.go +++ b/pipe_test.go @@ -1302,6 +1302,7 @@ func TestClientSideCachingWithNonRedisError(t *testing.T) { } func TestClientSideCachingMGet(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, cancel, _ := setup(t, ClientOption{}) defer cancel() @@ -1435,6 +1436,7 @@ func TestClientSideCachingMGet(t *testing.T) { } func TestClientSideCachingJSONMGet(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, cancel, _ := setup(t, ClientOption{}) defer cancel() @@ -1568,6 +1570,7 @@ func TestClientSideCachingJSONMGet(t *testing.T) { } func TestClientSideCachingExecAbortMGet(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, cancel, _ := setup(t, ClientOption{}) defer cancel() @@ -1602,6 +1605,7 @@ func TestClientSideCachingExecAbortMGet(t *testing.T) { } func TestClientSideCachingWithNonRedisErrorMGet(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, _, _, closeConn := setup(t, ClientOption{}) closeConn() @@ -1621,6 +1625,7 @@ func TestClientSideCachingWithNonRedisErrorMGet(t *testing.T) { } func TestClientSideCachingWithSideChannelMGet(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, _, _, closeConn := setup(t, ClientOption{}) closeConn() @@ -1639,6 +1644,7 @@ func TestClientSideCachingWithSideChannelMGet(t *testing.T) { } func TestClientSideCachingWithSideChannelErrorMGet(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, _, _, closeConn := setup(t, ClientOption{}) closeConn() @@ -1655,6 +1661,7 @@ func TestClientSideCachingWithSideChannelErrorMGet(t *testing.T) { } func TestClientSideCachingDoMultiCacheMGet(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, _, cancel, _ := setup(t, ClientOption{}) defer cancel() @@ -1669,6 +1676,7 @@ func TestClientSideCachingDoMultiCacheMGet(t *testing.T) { } func TestClientSideCachingDoMultiCache(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) testfn := func(t *testing.T, option ClientOption) { p, mock, cancel, _ := setup(t, option) defer cancel() @@ -1847,6 +1855,7 @@ func TestClientSideCachingDoMultiCache(t *testing.T) { } func TestClientSideCachingExecAbortDoMultiCache(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) testfn := func(t *testing.T, option ClientOption) { p, mock, cancel, _ := setup(t, option) defer cancel() @@ -1919,6 +1928,7 @@ func TestClientSideCachingExecAbortDoMultiCache(t *testing.T) { } func TestClientSideCachingWithNonRedisErrorDoMultiCache(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) testfn := func(t *testing.T, option ClientOption) { p, _, _, closeConn := setup(t, option) closeConn() @@ -1956,6 +1966,7 @@ func TestClientSideCachingWithNonRedisErrorDoMultiCache(t *testing.T) { } func TestClientSideCachingWithSideChannelDoMultiCache(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) testfn := func(t *testing.T, option ClientOption) { p, _, _, closeConn := setup(t, option) closeConn() @@ -1988,6 +1999,7 @@ func TestClientSideCachingWithSideChannelDoMultiCache(t *testing.T) { } func TestClientSideCachingWithSideChannelErrorDoMultiCache(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) testfn := func(t *testing.T, option ClientOption) { p, _, _, closeConn := setup(t, option) closeConn() @@ -2017,6 +2029,7 @@ func TestClientSideCachingWithSideChannelErrorDoMultiCache(t *testing.T) { } func TestClientSideCachingMissCacheTTL(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) testfn := func(t *testing.T, option ClientOption) { t.Run("DoCache GET", func(t *testing.T) { p, mock, cancel, _ := setup(t, option) @@ -2167,6 +2180,7 @@ func TestClientSideCachingMissCacheTTL(t *testing.T) { // https://github.com/redis/redis/issues/8935 func TestClientSideCachingRedis6InvalidationBug1(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, cancel, _ := setup(t, ClientOption{}) defer cancel() @@ -2228,6 +2242,7 @@ func TestClientSideCachingRedis6InvalidationBug1(t *testing.T) { // https://github.com/redis/redis/issues/8935 func TestClientSideCachingRedis6InvalidationBug2(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, cancel, _ := setup(t, ClientOption{}) defer cancel() @@ -2289,6 +2304,7 @@ func TestClientSideCachingRedis6InvalidationBug2(t *testing.T) { // https://github.com/redis/redis/issues/8935 func TestClientSideCachingRedis6InvalidationBugErr(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, _, closeConn := setup(t, ClientOption{}) expectCSC := func() { @@ -2325,6 +2341,7 @@ func TestClientSideCachingRedis6InvalidationBugErr(t *testing.T) { } func TestDisableClientSideCaching(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, cancel, _ := setup(t, ClientOption{DisableCache: true}) defer cancel() p.background() @@ -2361,6 +2378,7 @@ func TestDisableClientSideCaching(t *testing.T) { } func TestOnInvalidations(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) ch := make(chan []RedisMessage) _, mock, cancel, _ := setup(t, ClientOption{ OnInvalidations: func(messages []RedisMessage) { @@ -2404,6 +2422,7 @@ func TestOnInvalidations(t *testing.T) { } func TestMultiHalfErr(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, _, closeConn := setup(t, ClientOption{}) expectCSC := func() { @@ -2429,6 +2448,7 @@ func TestMultiHalfErr(t *testing.T) { //gocyclo:ignore func TestPubSub(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) builder := cmds.NewBuilder(cmds.NoSlot) t.Run("NoReply Commands In Do", func(t *testing.T) { p, mock, cancel, _ := setup(t, ClientOption{}) @@ -3002,6 +3022,7 @@ func TestPubSub(t *testing.T) { //gocyclo:ignore func TestPubSubHooks(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) builder := cmds.NewBuilder(cmds.NoSlot) t.Run("Empty Hooks", func(t *testing.T) { @@ -3221,6 +3242,7 @@ func TestPubSubHooks(t *testing.T) { } func TestExitOnWriteError(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, _, _, closeConn := setup(t, ClientOption{}) closeConn() @@ -3233,6 +3255,7 @@ func TestExitOnWriteError(t *testing.T) { } func TestExitOnPubSubSubscribeWriteError(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, _, _, closeConn := setup(t, ClientOption{}) activate := cmds.NewBuilder(cmds.NoSlot).Subscribe().Channel("a").Build() @@ -3258,6 +3281,7 @@ func TestExitOnPubSubSubscribeWriteError(t *testing.T) { } func TestExitOnWriteMultiError(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, _, _, closeConn := setup(t, ClientOption{}) closeConn() @@ -3270,6 +3294,7 @@ func TestExitOnWriteMultiError(t *testing.T) { } func TestExitOnRingFullAndConnError(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, _, closeConn := setup(t, ClientOption{ RingScaleEachConn: 1, }) @@ -3297,6 +3322,7 @@ func TestExitOnRingFullAndConnError(t *testing.T) { } func TestExitOnRingFullAndPingTimout(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, _, _ := setup(t, ClientOption{ RingScaleEachConn: 1, ConnWriteTimeout: 500 * time.Millisecond, @@ -3323,6 +3349,7 @@ func TestExitOnRingFullAndPingTimout(t *testing.T) { } func TestExitAllGoroutineOnWriteError(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) conn, mock, _, closeConn := setup(t, ClientOption{}) // start the background worker @@ -3349,6 +3376,7 @@ func TestExitAllGoroutineOnWriteError(t *testing.T) { } func TestExitOnReadError(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, _, closeConn := setup(t, ClientOption{}) go func() { @@ -3364,6 +3392,7 @@ func TestExitOnReadError(t *testing.T) { } func TestExitOnReadMultiError(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, _, closeConn := setup(t, ClientOption{}) go func() { @@ -3379,6 +3408,7 @@ func TestExitOnReadMultiError(t *testing.T) { } func TestExitAllGoroutineOnReadError(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, _, closeConn := setup(t, ClientOption{}) go func() { @@ -3404,6 +3434,7 @@ func TestExitAllGoroutineOnReadError(t *testing.T) { } func TestCloseAndWaitPendingCMDs(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, _, _ := setup(t, ClientOption{}) var ( @@ -3489,6 +3520,7 @@ func TestAlreadyCanceledContext(t *testing.T) { } func TestCancelContext_Do(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, shutdown, _ := setup(t, ClientOption{}) ctx, cancel := context.WithCancel(context.Background()) @@ -3544,6 +3576,7 @@ func TestWriteDeadlineIsShorterThanContextDeadline_DoStream(t *testing.T) { } func TestCancelContext_Do_Block(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, shutdown, _ := setup(t, ClientOption{}) ctx, cancel := context.WithCancel(context.Background()) @@ -3561,6 +3594,7 @@ func TestCancelContext_Do_Block(t *testing.T) { } func TestCancelContext_DoMulti(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, shutdown, _ := setup(t, ClientOption{}) ctx, cancel := context.WithCancel(context.Background()) @@ -3578,6 +3612,7 @@ func TestCancelContext_DoMulti(t *testing.T) { } func TestCancelContext_DoMulti_Block(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, shutdown, _ := setup(t, ClientOption{}) ctx, cancel := context.WithCancel(context.Background()) @@ -3633,6 +3668,7 @@ func TestWriteDeadlineIsShorterThanContextDeadline_DoMultiStream(t *testing.T) { } func TestForceClose_Do_Block(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, _, _ := setup(t, ClientOption{}) go func() { @@ -3691,6 +3727,7 @@ func TestForceClose_DoStream_Block(t *testing.T) { } func TestForceClose_Do_Canceled_Block(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, _, _ := setup(t, ClientOption{}) ctx, cancel := context.WithCancel(context.Background()) @@ -3708,6 +3745,7 @@ func TestForceClose_Do_Canceled_Block(t *testing.T) { } func TestForceClose_DoMulti_Block(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, _, _ := setup(t, ClientOption{}) go func() { @@ -3766,6 +3804,7 @@ func TestForceClose_DoMultiStream_Block(t *testing.T) { } func TestForceClose_DoMulti_Canceled_Block(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, _, _ := setup(t, ClientOption{}) ctx, cancel := context.WithCancel(context.Background()) @@ -3783,6 +3822,7 @@ func TestForceClose_DoMulti_Canceled_Block(t *testing.T) { } func TestSyncModeSwitchingWithDeadlineExceed_Do(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, _, closeConn := setup(t, ClientOption{}) defer closeConn() @@ -3808,6 +3848,7 @@ func TestSyncModeSwitchingWithDeadlineExceed_Do(t *testing.T) { } func TestSyncModeSwitchingWithDeadlineExceed_DoMulti(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, _, closeConn := setup(t, ClientOption{}) defer closeConn() @@ -3833,6 +3874,7 @@ func TestSyncModeSwitchingWithDeadlineExceed_DoMulti(t *testing.T) { } func TestOngoingDeadlineContextInSyncMode_Do(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, _, _, closeConn := setup(t, ClientOption{}) defer closeConn() @@ -3846,6 +3888,7 @@ func TestOngoingDeadlineContextInSyncMode_Do(t *testing.T) { } func TestWriteDeadlineInSyncMode_Do(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, _, _, closeConn := setup(t, ClientOption{ConnWriteTimeout: 1 * time.Second / 2, Dialer: net.Dialer{KeepAlive: time.Second / 3}}) defer closeConn() @@ -3856,6 +3899,7 @@ func TestWriteDeadlineInSyncMode_Do(t *testing.T) { } func TestWriteDeadlineIsShorterThanContextDeadlineInSyncMode_Do(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, _, _, closeConn := setup(t, ClientOption{ConnWriteTimeout: 100 * time.Millisecond, Dialer: net.Dialer{KeepAlive: time.Second}}) defer closeConn() @@ -3875,6 +3919,7 @@ func TestWriteDeadlineIsShorterThanContextDeadlineInSyncMode_Do(t *testing.T) { } func TestOngoingDeadlineContextInSyncMode_DoMulti(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, _, _, closeConn := setup(t, ClientOption{}) defer closeConn() @@ -3888,6 +3933,7 @@ func TestOngoingDeadlineContextInSyncMode_DoMulti(t *testing.T) { } func TestWriteDeadlineInSyncMode_DoMulti(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, _, _, closeConn := setup(t, ClientOption{ConnWriteTimeout: time.Second / 2, Dialer: net.Dialer{KeepAlive: time.Second / 3}}) defer closeConn() @@ -3898,6 +3944,7 @@ func TestWriteDeadlineInSyncMode_DoMulti(t *testing.T) { } func TestWriteDeadlineIsShorterThanContextDeadlineInSyncMode_DoMulti(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, _, _, closeConn := setup(t, ClientOption{ConnWriteTimeout: 100 * time.Millisecond, Dialer: net.Dialer{KeepAlive: time.Second}}) defer closeConn() @@ -3917,6 +3964,7 @@ func TestWriteDeadlineIsShorterThanContextDeadlineInSyncMode_DoMulti(t *testing. } func TestOngoingCancelContextInPipelineMode_Do(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, close, closeConn := setup(t, ClientOption{}) defer closeConn() @@ -3957,6 +4005,7 @@ func TestOngoingCancelContextInPipelineMode_Do(t *testing.T) { } func TestOngoingWriteTimeoutInPipelineMode_Do(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, _, _, closeConn := setup(t, ClientOption{ConnWriteTimeout: time.Second / 2, Dialer: net.Dialer{KeepAlive: time.Second / 3}}) defer closeConn() @@ -3989,6 +4038,7 @@ func TestOngoingWriteTimeoutInPipelineMode_Do(t *testing.T) { } func TestOngoingCancelContextInPipelineMode_DoMulti(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, close, closeConn := setup(t, ClientOption{}) defer closeConn() @@ -4029,6 +4079,7 @@ func TestOngoingCancelContextInPipelineMode_DoMulti(t *testing.T) { } func TestOngoingWriteTimeoutInPipelineMode_DoMulti(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, _, _, closeConn := setup(t, ClientOption{ConnWriteTimeout: time.Second / 2, Dialer: net.Dialer{KeepAlive: time.Second / 3}}) defer closeConn() @@ -4061,6 +4112,7 @@ func TestOngoingWriteTimeoutInPipelineMode_DoMulti(t *testing.T) { } func TestPipe_CleanSubscriptions_6(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, cancel, _ := setup(t, ClientOption{ConnWriteTimeout: time.Second / 2, Dialer: net.Dialer{KeepAlive: time.Second / 3}}) defer cancel() p.background() @@ -4081,6 +4133,7 @@ func TestPipe_CleanSubscriptions_6(t *testing.T) { } func TestPipe_CleanSubscriptions_7(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) p, mock, cancel, _ := setup(t, ClientOption{ConnWriteTimeout: time.Second / 2, Dialer: net.Dialer{KeepAlive: time.Second / 3}}) p.version = 7 defer cancel() @@ -4107,6 +4160,7 @@ func TestPipe_CleanSubscriptions_7(t *testing.T) { } func TestPingOnConnError(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) t.Run("sync", func(t *testing.T) { p, mock, _, closeConn := setup(t, ClientOption{ConnWriteTimeout: 3 * time.Second, Dialer: net.Dialer{KeepAlive: time.Second / 3}}) mock.Expect("PING") @@ -4132,6 +4186,7 @@ func TestPingOnConnError(t *testing.T) { //gocyclo:ignore func TestBlockingCommandNoDeadline(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) // blocking command should not apply timeout timeout := 100 * time.Millisecond t.Run("sync do", func(t *testing.T) { @@ -4223,6 +4278,7 @@ func TestBlockingCommandNoDeadline(t *testing.T) { } func TestDeadPipe(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) ctx := context.Background() if err := deadFn().Error(); err != ErrClosing { t.Fatalf("unexpected err %v", err) @@ -4245,6 +4301,7 @@ func TestDeadPipe(t *testing.T) { } func TestErrorPipe(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) ctx := context.Background() target := errors.New("any") if err := epipeFn(target).Error(); err != target { @@ -4268,6 +4325,7 @@ func TestErrorPipe(t *testing.T) { } func TestCloseHook(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) t.Run("normal close", func(t *testing.T) { var flag int32 p, _, cancel, _ := setup(t, ClientOption{}) @@ -4295,6 +4353,7 @@ func TestCloseHook(t *testing.T) { } func TestNoHelloRegex(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) tests := []struct { name string match bool diff --git a/pool_test.go b/pool_test.go index 14a2b03b..32fef647 100644 --- a/pool_test.go +++ b/pool_test.go @@ -177,6 +177,7 @@ func TestPool(t *testing.T) { } func TestPoolError(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) setup := func(size int) (*pool, *int32) { var count int32 return newPool(size, dead, func() wire { diff --git a/rueidis_test.go b/rueidis_test.go index 8a547348..c134518d 100644 --- a/rueidis_test.go +++ b/rueidis_test.go @@ -316,6 +316,7 @@ func TestTLSClient(t *testing.T) { } func TestNewClientMaxMultiplex(t *testing.T) { + defer ShouldNotLeaked(SetupLeakDetection()) _, err := NewClient(ClientOption{ InitAddress: []string{"127.0.0.1:6379"}, PipelineMultiplex: MaxPipelineMultiplex + 1,