diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2020-10-15 08:44:05 +0200 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2020-10-15 08:44:05 +0200 |
commit | 308948b3838c88621e738762241e8d1980881a17 (patch) | |
tree | 0cef7c4eb067c2320167634850598bd7d96cc953 /internal/command | |
parent | 3f03127314bd768efd0bef57915320545afcdd78 (diff) | |
download | gitlab-shell-zj-remove-testify-assert.tar.gz |
tests: Replace assert with requirezj-remove-testify-assert
Testify features sub packages `assert` and `require`. The difference is
subtle, and lost on novice Golang developers that don't read the docs.
To create a more consistent code base `assert` will no longer be used.
This change was generated by a running a sed command on all `_test.go`
files, followed by `goimports -w`.
Diffstat (limited to 'internal/command')
3 files changed, 9 insertions, 12 deletions
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"]) } |