From ee41d0dfb7b02a19f5926bfe24dbad1df417a29e Mon Sep 17 00:00:00 2001 From: Igor Drozdov Date: Wed, 17 Mar 2021 21:18:42 +0300 Subject: Replace cleanup functions with t.Cleanup In this case we don't need to propagate cleanup function. It simplifies the code. --- internal/gitlabnet/twofactorverify/client_test.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'internal/gitlabnet/twofactorverify/client_test.go') diff --git a/internal/gitlabnet/twofactorverify/client_test.go b/internal/gitlabnet/twofactorverify/client_test.go index 7bb037e..9893b12 100644 --- a/internal/gitlabnet/twofactorverify/client_test.go +++ b/internal/gitlabnet/twofactorverify/client_test.go @@ -81,8 +81,7 @@ const ( ) func TestVerifyOTPByKeyId(t *testing.T) { - client, cleanup := setup(t) - defer cleanup() + client := setup(t) args := &commandargs.Shell{GitlabKeyId: "0"} err := client.VerifyOTP(context.Background(), args, otpAttempt) @@ -90,8 +89,7 @@ func TestVerifyOTPByKeyId(t *testing.T) { } func TestVerifyOTPByUsername(t *testing.T) { - client, cleanup := setup(t) - defer cleanup() + client := setup(t) args := &commandargs.Shell{GitlabUsername: "jane-doe"} err := client.VerifyOTP(context.Background(), args, otpAttempt) @@ -99,8 +97,7 @@ func TestVerifyOTPByUsername(t *testing.T) { } func TestErrorMessage(t *testing.T) { - client, cleanup := setup(t) - defer cleanup() + client := setup(t) args := &commandargs.Shell{GitlabKeyId: "1"} err := client.VerifyOTP(context.Background(), args, otpAttempt) @@ -108,8 +105,7 @@ func TestErrorMessage(t *testing.T) { } func TestErrorResponses(t *testing.T) { - client, cleanup := setup(t) - defer cleanup() + client := setup(t) testCases := []struct { desc string @@ -143,12 +139,12 @@ func TestErrorResponses(t *testing.T) { } } -func setup(t *testing.T) (*Client, func()) { +func setup(t *testing.T) *Client { requests := initialize(t) - url, cleanup := testserver.StartSocketHttpServer(t, requests) + url := testserver.StartSocketHttpServer(t, requests) client, err := NewClient(&config.Config{GitlabUrl: url}) require.NoError(t, err) - return client, cleanup + return client } -- cgit v1.2.1