From d541aab1ff4cc97fb33f5533e112e7f943150cb6 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 26 Oct 2021 15:00:55 +0300 Subject: [PATCH] [#48] pool/test: remove `defer` for controller close We have go1.16 in go.mod and `gomock.NewController` comment indicates: ``` New in go1.14+, if you are passing a *testing.T into this function you no longer need to call ctrl.Finish() in your test methods. ``` Signed-off-by: Evgenii Stratonikov --- pool/pool_test.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/pool/pool_test.go b/pool/pool_test.go index a6e93585..ceb8a6ce 100644 --- a/pool/pool_test.go +++ b/pool/pool_test.go @@ -39,7 +39,6 @@ func TestBuildPoolClientFailed(t *testing.T) { func TestBuildPoolCreateSessionFailed(t *testing.T) { ctrl := gomock.NewController(t) - defer ctrl.Finish() key, err := keys.NewPrivateKey() require.NoError(t, err) @@ -68,9 +67,7 @@ func TestBuildPoolCreateSessionFailed(t *testing.T) { func TestBuildPoolOneNodeFailed(t *testing.T) { ctrl := gomock.NewController(t) - defer ctrl.Finish() ctrl2 := gomock.NewController(t) - defer ctrl2.Finish() key, err := keys.NewPrivateKey() require.NoError(t, err) @@ -143,7 +140,6 @@ func TestBuildPoolZeroNodes(t *testing.T) { func TestOneNode(t *testing.T) { ctrl := gomock.NewController(t) - defer ctrl.Finish() tok := session.NewToken() uid, err := uuid.New().MarshalBinary() @@ -180,7 +176,6 @@ func TestOneNode(t *testing.T) { func TestTwoNodes(t *testing.T) { ctrl := gomock.NewController(t) - defer ctrl.Finish() var tokens []*session.Token clientBuilder := func(opts ...client.Option) (client.Client, error) { @@ -221,9 +216,7 @@ func TestTwoNodes(t *testing.T) { func TestOneOfTwoFailed(t *testing.T) { ctrl := gomock.NewController(t) - defer ctrl.Finish() ctrl2 := gomock.NewController(t) - defer ctrl2.Finish() var tokens []*session.Token clientCount := -1 @@ -283,7 +276,6 @@ func TestOneOfTwoFailed(t *testing.T) { func TestTwoFailed(t *testing.T) { ctrl := gomock.NewController(t) - defer ctrl.Finish() clientBuilder := func(opts ...client.Option) (client.Client, error) { mockClient := NewMockClient(ctrl) @@ -329,7 +321,6 @@ func newToken(t *testing.T) *session.Token { func TestWaitPresence(t *testing.T) { ctrl := gomock.NewController(t) - defer ctrl.Finish() mockClient := NewMockClient(ctrl) mockClient.EXPECT().CreateSession(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes()