diff options
-rw-r--r-- | client/client_test.go | 109 | ||||
-rw-r--r-- | client/httpclient_test.go | 15 | ||||
-rw-r--r-- | client/httpsclient_test.go | 7 | ||||
-rw-r--r-- | internal/command/personalaccesstoken/personalaccesstoken_test.go | 7 | ||||
-rw-r--r-- | internal/command/twofactorrecover/twofactorrecover_test.go | 5 | ||||
-rw-r--r-- | internal/command/uploadpack/gitalycall_test.go | 9 | ||||
-rw-r--r-- | internal/config/config_test.go | 13 | ||||
-rw-r--r-- | internal/gitlabnet/discover/client_test.go | 17 | ||||
-rw-r--r-- | internal/gitlabnet/personalaccesstoken/client_test.go | 15 | ||||
-rw-r--r-- | internal/gitlabnet/twofactorrecover/client_test.go | 15 | ||||
-rw-r--r-- | internal/handler/exec_test.go | 5 | ||||
-rw-r--r-- | internal/pktline/pktline_test.go | 2 |
12 files changed, 104 insertions, 115 deletions
diff --git a/client/client_test.go b/client/client_test.go index e0650b2..9895012 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -12,7 +12,6 @@ import ( "testing" "github.com/sirupsen/logrus" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitlab-shell/client/testserver" "gitlab.com/gitlab-org/gitlab-shell/internal/testhelper" @@ -86,17 +85,17 @@ func testSuccessfulGet(t *testing.T, client *GitlabNetClient) { defer response.Body.Close() responseBody, err := ioutil.ReadAll(response.Body) - assert.NoError(t, err) - assert.Equal(t, string(responseBody), "Hello") + require.NoError(t, err) + require.Equal(t, string(responseBody), "Hello") require.True(t, testhelper.WaitForLogEvent(hook)) entries := hook.AllEntries() - assert.Equal(t, 1, len(entries)) - assert.Equal(t, logrus.InfoLevel, entries[0].Level) - assert.Contains(t, entries[0].Message, "method=GET") - assert.Contains(t, entries[0].Message, "status=200") - assert.Contains(t, entries[0].Message, "Finished HTTP request") - assert.Contains(t, entries[0].Message, "correlation_id=") + require.Equal(t, 1, len(entries)) + require.Equal(t, logrus.InfoLevel, entries[0].Level) + require.Contains(t, entries[0].Message, "method=GET") + require.Contains(t, entries[0].Message, "status=200") + require.Contains(t, entries[0].Message, "Finished HTTP request") + require.Contains(t, entries[0].Message, "correlation_id=") }) } @@ -112,17 +111,17 @@ func testSuccessfulPost(t *testing.T, client *GitlabNetClient) { defer response.Body.Close() responseBody, err := ioutil.ReadAll(response.Body) - assert.NoError(t, err) - assert.Equal(t, "Echo: {\"key\":\"value\"}", string(responseBody)) + require.NoError(t, err) + require.Equal(t, "Echo: {\"key\":\"value\"}", string(responseBody)) require.True(t, testhelper.WaitForLogEvent(hook)) entries := hook.AllEntries() - assert.Equal(t, 1, len(entries)) - assert.Equal(t, logrus.InfoLevel, entries[0].Level) - assert.Contains(t, entries[0].Message, "method=POST") - assert.Contains(t, entries[0].Message, "status=200") - assert.Contains(t, entries[0].Message, "Finished HTTP request") - assert.Contains(t, entries[0].Message, "correlation_id=") + require.Equal(t, 1, len(entries)) + require.Equal(t, logrus.InfoLevel, entries[0].Level) + require.Contains(t, entries[0].Message, "method=POST") + require.Contains(t, entries[0].Message, "status=200") + require.Contains(t, entries[0].Message, "Finished HTTP request") + require.Contains(t, entries[0].Message, "correlation_id=") }) } @@ -130,47 +129,47 @@ func testMissing(t *testing.T, client *GitlabNetClient) { t.Run("Missing error for GET", func(t *testing.T) { hook := testhelper.SetupLogger() response, err := client.Get(context.Background(), "/missing") - assert.EqualError(t, err, "Internal API error (404)") - assert.Nil(t, response) + require.EqualError(t, err, "Internal API error (404)") + require.Nil(t, response) require.True(t, testhelper.WaitForLogEvent(hook)) entries := hook.AllEntries() - assert.Equal(t, 1, len(entries)) - assert.Equal(t, logrus.InfoLevel, entries[0].Level) - assert.Contains(t, entries[0].Message, "method=GET") - assert.Contains(t, entries[0].Message, "status=404") - assert.Contains(t, entries[0].Message, "Internal API error") - assert.Contains(t, entries[0].Message, "correlation_id=") + require.Equal(t, 1, len(entries)) + require.Equal(t, logrus.InfoLevel, entries[0].Level) + require.Contains(t, entries[0].Message, "method=GET") + require.Contains(t, entries[0].Message, "status=404") + require.Contains(t, entries[0].Message, "Internal API error") + require.Contains(t, entries[0].Message, "correlation_id=") }) t.Run("Missing error for POST", func(t *testing.T) { hook := testhelper.SetupLogger() response, err := client.Post(context.Background(), "/missing", map[string]string{}) - assert.EqualError(t, err, "Internal API error (404)") - assert.Nil(t, response) + require.EqualError(t, err, "Internal API error (404)") + require.Nil(t, response) require.True(t, testhelper.WaitForLogEvent(hook)) entries := hook.AllEntries() - assert.Equal(t, 1, len(entries)) - assert.Equal(t, logrus.InfoLevel, entries[0].Level) - assert.Contains(t, entries[0].Message, "method=POST") - assert.Contains(t, entries[0].Message, "status=404") - assert.Contains(t, entries[0].Message, "Internal API error") - assert.Contains(t, entries[0].Message, "correlation_id=") + require.Equal(t, 1, len(entries)) + require.Equal(t, logrus.InfoLevel, entries[0].Level) + require.Contains(t, entries[0].Message, "method=POST") + require.Contains(t, entries[0].Message, "status=404") + require.Contains(t, entries[0].Message, "Internal API error") + require.Contains(t, entries[0].Message, "correlation_id=") }) } func testErrorMessage(t *testing.T, client *GitlabNetClient) { t.Run("Error with message for GET", func(t *testing.T) { response, err := client.Get(context.Background(), "/error") - assert.EqualError(t, err, "Don't do that") - assert.Nil(t, response) + require.EqualError(t, err, "Don't do that") + require.Nil(t, response) }) t.Run("Error with message for POST", func(t *testing.T) { response, err := client.Post(context.Background(), "/error", map[string]string{}) - assert.EqualError(t, err, "Don't do that") - assert.Nil(t, response) + require.EqualError(t, err, "Don't do that") + require.Nil(t, response) }) } @@ -179,34 +178,34 @@ func testBrokenRequest(t *testing.T, client *GitlabNetClient) { hook := testhelper.SetupLogger() response, err := client.Get(context.Background(), "/broken") - assert.EqualError(t, err, "Internal API unreachable") - assert.Nil(t, response) + require.EqualError(t, err, "Internal API unreachable") + require.Nil(t, response) require.True(t, testhelper.WaitForLogEvent(hook)) entries := hook.AllEntries() - assert.Equal(t, 1, len(entries)) - assert.Equal(t, logrus.InfoLevel, entries[0].Level) - assert.Contains(t, entries[0].Message, "method=GET") - assert.NotContains(t, entries[0].Message, "status=") - assert.Contains(t, entries[0].Message, "Internal API unreachable") - assert.Contains(t, entries[0].Message, "correlation_id=") + require.Equal(t, 1, len(entries)) + require.Equal(t, logrus.InfoLevel, entries[0].Level) + require.Contains(t, entries[0].Message, "method=GET") + require.NotContains(t, entries[0].Message, "status=") + require.Contains(t, entries[0].Message, "Internal API unreachable") + require.Contains(t, entries[0].Message, "correlation_id=") }) t.Run("Broken request for POST", func(t *testing.T) { hook := testhelper.SetupLogger() response, err := client.Post(context.Background(), "/broken", map[string]string{}) - assert.EqualError(t, err, "Internal API unreachable") - assert.Nil(t, response) + require.EqualError(t, err, "Internal API unreachable") + require.Nil(t, response) require.True(t, testhelper.WaitForLogEvent(hook)) entries := hook.AllEntries() - assert.Equal(t, 1, len(entries)) - assert.Equal(t, logrus.InfoLevel, entries[0].Level) - assert.Contains(t, entries[0].Message, "method=POST") - assert.NotContains(t, entries[0].Message, "status=") - assert.Contains(t, entries[0].Message, "Internal API unreachable") - assert.Contains(t, entries[0].Message, "correlation_id=") + require.Equal(t, 1, len(entries)) + require.Equal(t, logrus.InfoLevel, entries[0].Level) + require.Contains(t, entries[0].Message, "method=POST") + require.NotContains(t, entries[0].Message, "status=") + require.Contains(t, entries[0].Message, "Internal API unreachable") + require.Contains(t, entries[0].Message, "correlation_id=") }) } @@ -223,7 +222,7 @@ func testAuthenticationHeader(t *testing.T, client *GitlabNetClient) { header, err := base64.StdEncoding.DecodeString(string(responseBody)) require.NoError(t, err) - assert.Equal(t, "sssh, it's a secret", string(header)) + require.Equal(t, "sssh, it's a secret", string(header)) }) t.Run("Authentication headers for POST", func(t *testing.T) { @@ -238,7 +237,7 @@ func testAuthenticationHeader(t *testing.T, client *GitlabNetClient) { header, err := base64.StdEncoding.DecodeString(string(responseBody)) require.NoError(t, err) - assert.Equal(t, "sssh, it's a secret", string(header)) + require.Equal(t, "sssh, it's a secret", string(header)) }) } diff --git a/client/httpclient_test.go b/client/httpclient_test.go index 59dabc4..2d2a06e 100644 --- a/client/httpclient_test.go +++ b/client/httpclient_test.go @@ -10,7 +10,6 @@ import ( "testing" "time" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitlab-shell/client/testserver" ) @@ -21,7 +20,7 @@ func TestReadTimeout(t *testing.T) { client := NewHTTPClient("http://localhost:3000", "", "", "", false, expectedSeconds) require.NotNil(t, client) - assert.Equal(t, time.Duration(expectedSeconds)*time.Second, client.Client.Timeout) + require.Equal(t, time.Duration(expectedSeconds)*time.Second, client.Client.Timeout) } const ( @@ -66,15 +65,15 @@ func testBasicAuthHeaders(t *testing.T, response *http.Response) { require.NotNil(t, response) responseBody, err := ioutil.ReadAll(response.Body) - assert.NoError(t, err) + require.NoError(t, err) headerParts := strings.Split(string(responseBody), " ") - assert.Equal(t, "Basic", headerParts[0]) + require.Equal(t, "Basic", headerParts[0]) credentials, err := base64.StdEncoding.DecodeString(headerParts[1]) require.NoError(t, err) - assert.Equal(t, username+":"+password, string(credentials)) + require.Equal(t, username+":"+password, string(credentials)) } func TestEmptyBasicAuthSettings(t *testing.T) { @@ -82,7 +81,7 @@ func TestEmptyBasicAuthSettings(t *testing.T) { { Path: "/api/v4/internal/empty_basic_auth", Handler: func(w http.ResponseWriter, r *http.Request) { - assert.Equal(t, "", r.Header.Get("Authorization")) + require.Equal(t, "", r.Header.Get("Authorization")) }, }, } @@ -100,13 +99,13 @@ func TestRequestWithUserAgent(t *testing.T) { { Path: "/api/v4/internal/default_user_agent", Handler: func(w http.ResponseWriter, r *http.Request) { - assert.Equal(t, defaultUserAgent, r.UserAgent()) + require.Equal(t, defaultUserAgent, r.UserAgent()) }, }, { Path: "/api/v4/internal/override_user_agent", Handler: func(w http.ResponseWriter, r *http.Request) { - assert.Equal(t, gitalyUserAgent, r.UserAgent()) + require.Equal(t, gitalyUserAgent, r.UserAgent()) }, }, } diff --git a/client/httpsclient_test.go b/client/httpsclient_test.go index 0cf77e3..d76890b 100644 --- a/client/httpsclient_test.go +++ b/client/httpsclient_test.go @@ -8,7 +8,6 @@ import ( "path" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitlab-shell/client/testserver" "gitlab.com/gitlab-org/gitlab-shell/internal/testhelper" @@ -51,8 +50,8 @@ func TestSuccessfulRequests(t *testing.T) { defer response.Body.Close() responseBody, err := ioutil.ReadAll(response.Body) - assert.NoError(t, err) - assert.Equal(t, string(responseBody), "Hello") + require.NoError(t, err) + require.Equal(t, string(responseBody), "Hello") }) } } @@ -84,7 +83,7 @@ func TestFailedRequests(t *testing.T) { _, err := client.Get(context.Background(), "/hello") require.Error(t, err) - assert.Equal(t, err.Error(), "Internal API unreachable") + require.Equal(t, err.Error(), "Internal API unreachable") }) } } diff --git a/internal/command/personalaccesstoken/personalaccesstoken_test.go b/internal/command/personalaccesstoken/personalaccesstoken_test.go index 5970142..aa56ce9 100644 --- a/internal/command/personalaccesstoken/personalaccesstoken_test.go +++ b/internal/command/personalaccesstoken/personalaccesstoken_test.go @@ -8,7 +8,6 @@ import ( "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitlab-shell/client/testserver" @@ -174,13 +173,13 @@ func TestExecute(t *testing.T) { err := cmd.Execute(context.Background()) if tc.expectedError == "" { - assert.NoError(t, err) + require.NoError(t, err) } else { - assert.EqualError(t, err, tc.expectedError) + require.EqualError(t, err, tc.expectedError) } if tc.expectedOutput != "" { - assert.Equal(t, tc.expectedOutput, output.String()) + require.Equal(t, tc.expectedOutput, output.String()) } }) } diff --git a/internal/command/twofactorrecover/twofactorrecover_test.go b/internal/command/twofactorrecover/twofactorrecover_test.go index ea6abd6..92e3779 100644 --- a/internal/command/twofactorrecover/twofactorrecover_test.go +++ b/internal/command/twofactorrecover/twofactorrecover_test.go @@ -8,7 +8,6 @@ import ( "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitlab-shell/client/testserver" @@ -130,8 +129,8 @@ func TestExecute(t *testing.T) { err := cmd.Execute(context.Background()) - assert.NoError(t, err) - assert.Equal(t, tc.expectedOutput, output.String()) + require.NoError(t, err) + require.Equal(t, tc.expectedOutput, output.String()) }) } } diff --git a/internal/command/uploadpack/gitalycall_test.go b/internal/command/uploadpack/gitalycall_test.go index 22189b8..d49e11e 100644 --- a/internal/command/uploadpack/gitalycall_test.go +++ b/internal/command/uploadpack/gitalycall_test.go @@ -5,7 +5,6 @@ import ( "context" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitlab-shell/client/testserver" @@ -43,7 +42,7 @@ func TestUploadPack(t *testing.T) { require.Equal(t, "UploadPack: "+repo, output.String()) entries := hook.AllEntries() - assert.Equal(t, 2, len(entries)) + require.Equal(t, 2, len(entries)) require.Contains(t, entries[1].Message, "executing git command") require.Contains(t, entries[1].Message, "command=git-upload-pack") require.Contains(t, entries[1].Message, "gl_key_type=key") @@ -54,8 +53,8 @@ func TestUploadPack(t *testing.T) { "gitaly-feature-inforef_uploadpack_cache": "false", } { actual := testServer.ReceivedMD[k] - assert.Len(t, actual, 1) - assert.Equal(t, v, actual[0]) + require.Len(t, actual, 1) + require.Equal(t, v, actual[0]) } - assert.Empty(t, testServer.ReceivedMD["some-other-ff"]) + require.Empty(t, testServer.ReceivedMD["some-other-ff"]) } diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 77351f2..f90e73c 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -5,7 +5,6 @@ import ( "path" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitlab-shell/internal/testhelper" ) @@ -110,12 +109,12 @@ func TestParseConfig(t *testing.T) { err := parseConfig([]byte(tc.yaml), &cfg) require.NoError(t, err) - assert.Equal(t, tc.path, cfg.LogFile) - assert.Equal(t, tc.format, cfg.LogFormat) - assert.Equal(t, tc.gitlabUrl, cfg.GitlabUrl) - assert.Equal(t, tc.secret, cfg.Secret) - assert.Equal(t, tc.sslCertDir, cfg.SslCertDir) - assert.Equal(t, tc.httpSettings, cfg.HttpSettings) + require.Equal(t, tc.path, cfg.LogFile) + require.Equal(t, tc.format, cfg.LogFormat) + require.Equal(t, tc.gitlabUrl, cfg.GitlabUrl) + require.Equal(t, tc.secret, cfg.Secret) + require.Equal(t, tc.sslCertDir, cfg.SslCertDir) + require.Equal(t, tc.httpSettings, cfg.HttpSettings) }) } } diff --git a/internal/gitlabnet/discover/client_test.go b/internal/gitlabnet/discover/client_test.go index cb46dd7..d1b5039 100644 --- a/internal/gitlabnet/discover/client_test.go +++ b/internal/gitlabnet/discover/client_test.go @@ -10,7 +10,6 @@ import ( "gitlab.com/gitlab-org/gitlab-shell/client" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitlab-shell/client/testserver" "gitlab.com/gitlab-org/gitlab-shell/internal/config" @@ -64,8 +63,8 @@ func TestGetByKeyId(t *testing.T) { params := url.Values{} params.Add("key_id", "1") result, err := client.getResponse(context.Background(), params) - assert.NoError(t, err) - assert.Equal(t, &Response{UserId: 2, Username: "alex-doe", Name: "Alex Doe"}, result) + require.NoError(t, err) + require.Equal(t, &Response{UserId: 2, Username: "alex-doe", Name: "Alex Doe"}, result) } func TestGetByUsername(t *testing.T) { @@ -75,8 +74,8 @@ func TestGetByUsername(t *testing.T) { params := url.Values{} params.Add("username", "jane-doe") result, err := client.getResponse(context.Background(), params) - assert.NoError(t, err) - assert.Equal(t, &Response{UserId: 1, Username: "jane-doe", Name: "Jane Doe"}, result) + require.NoError(t, err) + require.Equal(t, &Response{UserId: 1, Username: "jane-doe", Name: "Jane Doe"}, result) } func TestMissingUser(t *testing.T) { @@ -86,8 +85,8 @@ func TestMissingUser(t *testing.T) { params := url.Values{} params.Add("username", "missing") result, err := client.getResponse(context.Background(), params) - assert.NoError(t, err) - assert.True(t, result.IsAnonymous()) + require.NoError(t, err) + require.True(t, result.IsAnonymous()) } func TestErrorResponses(t *testing.T) { @@ -122,8 +121,8 @@ func TestErrorResponses(t *testing.T) { params.Add("username", tc.fakeUsername) resp, err := client.getResponse(context.Background(), params) - assert.EqualError(t, err, tc.expectedError) - assert.Nil(t, resp) + require.EqualError(t, err, tc.expectedError) + require.Nil(t, resp) }) } } diff --git a/internal/gitlabnet/personalaccesstoken/client_test.go b/internal/gitlabnet/personalaccesstoken/client_test.go index 140a7b2..d9c3f45 100644 --- a/internal/gitlabnet/personalaccesstoken/client_test.go +++ b/internal/gitlabnet/personalaccesstoken/client_test.go @@ -7,7 +7,6 @@ import ( "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitlab-shell/client" "gitlab.com/gitlab-org/gitlab-shell/client/testserver" @@ -93,7 +92,7 @@ func TestGetPersonalAccessTokenByKeyId(t *testing.T) { result, err := client.GetPersonalAccessToken( context.Background(), args, "newtoken", &[]string{"read_api", "read_repository"}, "", ) - assert.NoError(t, err) + require.NoError(t, err) response := &Response{ true, "aAY1G3YPeemECgUvxuXY", @@ -101,7 +100,7 @@ func TestGetPersonalAccessTokenByKeyId(t *testing.T) { "9001-11-17", "", } - assert.Equal(t, response, result) + require.Equal(t, response, result) } func TestGetRecoveryCodesByUsername(t *testing.T) { @@ -112,9 +111,9 @@ func TestGetRecoveryCodesByUsername(t *testing.T) { result, err := client.GetPersonalAccessToken( context.Background(), args, "newtoken", &[]string{"api"}, "", ) - assert.NoError(t, err) + require.NoError(t, err) response := &Response{true, "YXuxvUgCEmeePY3G1YAa", []string{"api"}, "", ""} - assert.Equal(t, response, result) + require.Equal(t, response, result) } func TestMissingUser(t *testing.T) { @@ -125,7 +124,7 @@ func TestMissingUser(t *testing.T) { _, err := client.GetPersonalAccessToken( context.Background(), args, "newtoken", &[]string{"api"}, "", ) - assert.Equal(t, "missing user", err.Error()) + require.Equal(t, "missing user", err.Error()) } func TestErrorResponses(t *testing.T) { @@ -161,8 +160,8 @@ func TestErrorResponses(t *testing.T) { context.Background(), args, "newtoken", &[]string{"api"}, "", ) - assert.EqualError(t, err, tc.expectedError) - assert.Nil(t, resp) + require.EqualError(t, err, tc.expectedError) + require.Nil(t, resp) }) } } diff --git a/internal/gitlabnet/twofactorrecover/client_test.go b/internal/gitlabnet/twofactorrecover/client_test.go index 46291aa..55656a8 100644 --- a/internal/gitlabnet/twofactorrecover/client_test.go +++ b/internal/gitlabnet/twofactorrecover/client_test.go @@ -7,7 +7,6 @@ import ( "net/http" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gitlab.com/gitlab-org/gitlab-shell/client" "gitlab.com/gitlab-org/gitlab-shell/client/testserver" @@ -87,8 +86,8 @@ func TestGetRecoveryCodesByKeyId(t *testing.T) { args := &commandargs.Shell{GitlabKeyId: "0"} result, err := client.GetRecoveryCodes(context.Background(), args) - assert.NoError(t, err) - assert.Equal(t, []string{"recovery 1", "codes 1"}, result) + require.NoError(t, err) + require.Equal(t, []string{"recovery 1", "codes 1"}, result) } func TestGetRecoveryCodesByUsername(t *testing.T) { @@ -97,8 +96,8 @@ func TestGetRecoveryCodesByUsername(t *testing.T) { args := &commandargs.Shell{GitlabUsername: "jane-doe"} result, err := client.GetRecoveryCodes(context.Background(), args) - assert.NoError(t, err) - assert.Equal(t, []string{"recovery 2", "codes 2"}, result) + require.NoError(t, err) + require.Equal(t, []string{"recovery 2", "codes 2"}, result) } func TestMissingUser(t *testing.T) { @@ -107,7 +106,7 @@ func TestMissingUser(t *testing.T) { args := &commandargs.Shell{GitlabKeyId: "1"} _, err := client.GetRecoveryCodes(context.Background(), args) - assert.Equal(t, "missing user", err.Error()) + require.Equal(t, "missing user", err.Error()) } func TestErrorResponses(t *testing.T) { @@ -141,8 +140,8 @@ func TestErrorResponses(t *testing.T) { args := &commandargs.Shell{GitlabKeyId: tc.fakeId} resp, err := client.GetRecoveryCodes(context.Background(), args) - assert.EqualError(t, err, tc.expectedError) - assert.Nil(t, resp) + require.EqualError(t, err, tc.expectedError) + require.Nil(t, resp) }) } } diff --git a/internal/handler/exec_test.go b/internal/handler/exec_test.go index 7c85e16..ce672f4 100644 --- a/internal/handler/exec_test.go +++ b/internal/handler/exec_test.go @@ -5,7 +5,6 @@ import ( "errors" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "google.golang.org/grpc" "google.golang.org/grpc/metadata" @@ -77,8 +76,8 @@ func TestGetConnMetadata(t *testing.T) { for k, v := range tt.want { values := md.Get(k) - assert.Equal(t, 1, len(values)) - assert.Equal(t, v, values[0]) + require.Equal(t, 1, len(values)) + require.Equal(t, v, values[0]) } }) diff --git a/internal/pktline/pktline_test.go b/internal/pktline/pktline_test.go index cf3f6fd..6910c1e 100644 --- a/internal/pktline/pktline_test.go +++ b/internal/pktline/pktline_test.go @@ -70,7 +70,7 @@ func TestScanner(t *testing.T) { func TestIsDone(t *testing.T) { testCases := []struct { - in string + in string done bool }{ {in: "0008abcd", done: false}, |