Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
3701cc77
Commit
3701cc77
authored
Sep 16, 2020
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove last cases of testify/assert
parent
7d8c1f55
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
99 additions
and
105 deletions
+99
-105
gitaly_integration_test.go
gitaly_integration_test.go
+14
-15
gitaly_test.go
gitaly_test.go
+20
-21
jobs_test.go
jobs_test.go
+4
-4
main_test.go
main_test.go
+59
-62
upload_test.go
upload_test.go
+2
-3
No files found.
gitaly_integration_test.go
View file @
3701cc77
...
...
@@ -16,7 +16,6 @@ import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
...
...
@@ -178,10 +177,10 @@ func TestAllowedGetGitBlob(t *testing.T) {
require
.
NoError
(
t
,
err
)
shortBody
:=
string
(
body
[
:
len
(
expectedBody
)])
assert
.
Equal
(
t
,
200
,
resp
.
StatusCode
,
"GET %q: status code"
,
resp
.
Request
.
URL
)
assert
.
Equal
(
t
,
expectedBody
,
shortBody
,
"GET %q: response body"
,
resp
.
Request
.
URL
)
require
.
Equal
(
t
,
200
,
resp
.
StatusCode
,
"GET %q: status code"
,
resp
.
Request
.
URL
)
require
.
Equal
(
t
,
expectedBody
,
shortBody
,
"GET %q: response body"
,
resp
.
Request
.
URL
)
testhelper
.
RequireResponseHeader
(
t
,
resp
,
"Content-Length"
,
strconv
.
Itoa
(
bodyLen
))
assert
NginxResponseBuffering
(
t
,
"no"
,
resp
,
"GET %q: nginx response buffering"
,
resp
.
Request
.
URL
)
require
NginxResponseBuffering
(
t
,
"no"
,
resp
,
"GET %q: nginx response buffering"
,
resp
.
Request
.
URL
)
}
func
TestAllowedGetGitArchive
(
t
*
testing
.
T
)
{
...
...
@@ -205,8 +204,8 @@ func TestAllowedGetGitArchive(t *testing.T) {
resp
,
body
,
err
:=
doSendDataRequest
(
"/archive.tar"
,
"git-archive"
,
jsonParams
)
require
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
200
,
resp
.
StatusCode
,
"GET %q: status code"
,
resp
.
Request
.
URL
)
assert
NginxResponseBuffering
(
t
,
"no"
,
resp
,
"GET %q: nginx response buffering"
,
resp
.
Request
.
URL
)
require
.
Equal
(
t
,
200
,
resp
.
StatusCode
,
"GET %q: status code"
,
resp
.
Request
.
URL
)
require
NginxResponseBuffering
(
t
,
"no"
,
resp
,
"GET %q: nginx response buffering"
,
resp
.
Request
.
URL
)
// Ensure the tar file is readable
foundEntry
:=
false
...
...
@@ -223,7 +222,7 @@ func TestAllowedGetGitArchive(t *testing.T) {
}
}
assert
.
True
(
t
,
foundEntry
,
"Couldn't find %v directory entry"
,
archivePrefix
)
require
.
True
(
t
,
foundEntry
,
"Couldn't find %v directory entry"
,
archivePrefix
)
}
func
TestAllowedGetGitArchiveOldPayload
(
t
*
testing
.
T
)
{
...
...
@@ -250,8 +249,8 @@ func TestAllowedGetGitArchiveOldPayload(t *testing.T) {
resp
,
body
,
err
:=
doSendDataRequest
(
"/archive.tar"
,
"git-archive"
,
jsonParams
)
require
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
200
,
resp
.
StatusCode
,
"GET %q: status code"
,
resp
.
Request
.
URL
)
assert
NginxResponseBuffering
(
t
,
"no"
,
resp
,
"GET %q: nginx response buffering"
,
resp
.
Request
.
URL
)
require
.
Equal
(
t
,
200
,
resp
.
StatusCode
,
"GET %q: status code"
,
resp
.
Request
.
URL
)
require
NginxResponseBuffering
(
t
,
"no"
,
resp
,
"GET %q: nginx response buffering"
,
resp
.
Request
.
URL
)
// Ensure the tar file is readable
foundEntry
:=
false
...
...
@@ -268,7 +267,7 @@ func TestAllowedGetGitArchiveOldPayload(t *testing.T) {
}
}
assert
.
True
(
t
,
foundEntry
,
"Couldn't find %v directory entry"
,
archivePrefix
)
require
.
True
(
t
,
foundEntry
,
"Couldn't find %v directory entry"
,
archivePrefix
)
}
func
TestAllowedGetGitDiff
(
t
*
testing
.
T
)
{
...
...
@@ -293,9 +292,9 @@ func TestAllowedGetGitDiff(t *testing.T) {
require
.
NoError
(
t
,
err
)
shortBody
:=
string
(
body
[
:
len
(
expectedBody
)])
assert
.
Equal
(
t
,
200
,
resp
.
StatusCode
,
"GET %q: status code"
,
resp
.
Request
.
URL
)
assert
.
Equal
(
t
,
expectedBody
,
shortBody
,
"GET %q: response body"
,
resp
.
Request
.
URL
)
assert
NginxResponseBuffering
(
t
,
"no"
,
resp
,
"GET %q: nginx response buffering"
,
resp
.
Request
.
URL
)
require
.
Equal
(
t
,
200
,
resp
.
StatusCode
,
"GET %q: status code"
,
resp
.
Request
.
URL
)
require
.
Equal
(
t
,
expectedBody
,
shortBody
,
"GET %q: response body"
,
resp
.
Request
.
URL
)
require
NginxResponseBuffering
(
t
,
"no"
,
resp
,
"GET %q: nginx response buffering"
,
resp
.
Request
.
URL
)
}
func
TestAllowedGetGitFormatPatch
(
t
*
testing
.
T
)
{
...
...
@@ -317,8 +316,8 @@ func TestAllowedGetGitFormatPatch(t *testing.T) {
resp
,
body
,
err
:=
doSendDataRequest
(
"/something"
,
"git-format-patch"
,
jsonParams
)
require
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
200
,
resp
.
StatusCode
,
"GET %q: status code"
,
resp
.
Request
.
URL
)
assert
NginxResponseBuffering
(
t
,
"no"
,
resp
,
"GET %q: nginx response buffering"
,
resp
.
Request
.
URL
)
require
.
Equal
(
t
,
200
,
resp
.
StatusCode
,
"GET %q: status code"
,
resp
.
Request
.
URL
)
require
NginxResponseBuffering
(
t
,
"no"
,
resp
,
"GET %q: nginx response buffering"
,
resp
.
Request
.
URL
)
requirePatchSeries
(
t
,
...
...
gitaly_test.go
View file @
3701cc77
...
...
@@ -19,7 +19,6 @@ import (
"github.com/golang/protobuf/jsonpb"
//lint:ignore SA1019 https://gitlab.com/gitlab-org/gitlab-workhorse/-/issues/274
"github.com/golang/protobuf/proto"
//lint:ignore SA1019 https://gitlab.com/gitlab-org/gitlab-workhorse/-/issues/274
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
...
...
@@ -53,7 +52,7 @@ func TestFailedCloneNoGitaly(t *testing.T) {
cloneCmd
:=
exec
.
Command
(
"git"
,
"clone"
,
fmt
.
Sprintf
(
"%s/%s"
,
ws
.
URL
,
testRepo
),
checkoutDir
)
out
,
err
:=
cloneCmd
.
CombinedOutput
()
t
.
Log
(
string
(
out
))
assert
.
Error
(
t
,
err
,
"git clone should have failed"
)
require
.
Error
(
t
,
err
,
"git clone should have failed"
)
}
func
TestGetInfoRefsProxiedToGitalySuccessfully
(
t
*
testing
.
T
)
{
...
...
@@ -214,14 +213,14 @@ func TestPostReceivePackProxiedToGitalySuccessfully(t *testing.T) {
gitalyRequest
:=
&
gitalypb
.
PostReceivePackRequest
{}
require
.
NoError
(
t
,
jsonpb
.
UnmarshalString
(
split
[
0
],
gitalyRequest
))
assert
.
Equal
(
t
,
apiResponse
.
Repository
.
StorageName
,
gitalyRequest
.
Repository
.
StorageName
)
assert
.
Equal
(
t
,
apiResponse
.
Repository
.
RelativePath
,
gitalyRequest
.
Repository
.
RelativePath
)
assert
.
Equal
(
t
,
apiResponse
.
GL_ID
,
gitalyRequest
.
GlId
)
assert
.
Equal
(
t
,
apiResponse
.
GL_USERNAME
,
gitalyRequest
.
GlUsername
)
assert
.
Equal
(
t
,
apiResponse
.
GitConfigOptions
,
gitalyRequest
.
GitConfigOptions
)
assert
.
Equal
(
t
,
gitProtocol
,
gitalyRequest
.
GitProtocol
)
require
.
Equal
(
t
,
apiResponse
.
Repository
.
StorageName
,
gitalyRequest
.
Repository
.
StorageName
)
require
.
Equal
(
t
,
apiResponse
.
Repository
.
RelativePath
,
gitalyRequest
.
Repository
.
RelativePath
)
require
.
Equal
(
t
,
apiResponse
.
GL_ID
,
gitalyRequest
.
GlId
)
require
.
Equal
(
t
,
apiResponse
.
GL_USERNAME
,
gitalyRequest
.
GlUsername
)
require
.
Equal
(
t
,
apiResponse
.
GitConfigOptions
,
gitalyRequest
.
GitConfigOptions
)
require
.
Equal
(
t
,
gitProtocol
,
gitalyRequest
.
GitProtocol
)
assert
.
Equal
(
t
,
200
,
resp
.
StatusCode
,
"POST %q"
,
resource
)
require
.
Equal
(
t
,
200
,
resp
.
StatusCode
,
"POST %q"
,
resource
)
require
.
Equal
(
t
,
string
(
testhelper
.
GitalyReceivePackResponseMock
),
split
[
1
])
testhelper
.
RequireResponseHeader
(
t
,
resp
,
"Content-Type"
,
"application/x-git-receive-pack-result"
)
}
...
...
@@ -246,7 +245,7 @@ func TestPostReceivePackProxiedToGitalyInterrupted(t *testing.T) {
bytes
.
NewReader
(
testhelper
.
GitalyReceivePackResponseMock
),
)
require
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
200
,
resp
.
StatusCode
,
"POST %q"
,
resource
)
require
.
Equal
(
t
,
200
,
resp
.
StatusCode
,
"POST %q"
,
resource
)
// This causes the server stream to be interrupted instead of consumed entirely.
resp
.
Body
.
Close
()
...
...
@@ -363,7 +362,7 @@ func TestPostUploadPackProxiedToGitalyInterrupted(t *testing.T) {
bytes
.
NewReader
(
testhelper
.
GitalyUploadPackResponseMock
),
)
require
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
200
,
resp
.
StatusCode
,
"POST %q"
,
resource
)
require
.
Equal
(
t
,
200
,
resp
.
StatusCode
,
"POST %q"
,
resource
)
// This causes the server stream to be interrupted instead of consumed entirely.
resp
.
Body
.
Close
()
...
...
@@ -393,8 +392,8 @@ func TestGetDiffProxiedToGitalySuccessfully(t *testing.T) {
resp
,
body
,
err
:=
doSendDataRequest
(
"/something"
,
"git-diff"
,
jsonParams
)
require
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
200
,
resp
.
StatusCode
,
"GET %q: status code"
,
resp
.
Request
.
URL
)
assert
.
Equal
(
t
,
expectedBody
,
string
(
body
),
"GET %q: response body"
,
resp
.
Request
.
URL
)
require
.
Equal
(
t
,
200
,
resp
.
StatusCode
,
"GET %q: status code"
,
resp
.
Request
.
URL
)
require
.
Equal
(
t
,
expectedBody
,
string
(
body
),
"GET %q: response body"
,
resp
.
Request
.
URL
)
}
func
TestGetPatchProxiedToGitalySuccessfully
(
t
*
testing
.
T
)
{
...
...
@@ -413,8 +412,8 @@ func TestGetPatchProxiedToGitalySuccessfully(t *testing.T) {
resp
,
body
,
err
:=
doSendDataRequest
(
"/something"
,
"git-format-patch"
,
jsonParams
)
require
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
200
,
resp
.
StatusCode
,
"GET %q: status code"
,
resp
.
Request
.
URL
)
assert
.
Equal
(
t
,
expectedBody
,
string
(
body
),
"GET %q: response body"
,
resp
.
Request
.
URL
)
require
.
Equal
(
t
,
200
,
resp
.
StatusCode
,
"GET %q: status code"
,
resp
.
Request
.
URL
)
require
.
Equal
(
t
,
expectedBody
,
string
(
body
),
"GET %q: response body"
,
resp
.
Request
.
URL
)
}
func
TestGetBlobProxiedToGitalyInterruptedStream
(
t
*
testing
.
T
)
{
...
...
@@ -469,9 +468,9 @@ func TestGetArchiveProxiedToGitalySuccessfully(t *testing.T) {
resp
,
body
,
err
:=
doSendDataRequest
(
"/archive.tar.gz"
,
"git-archive"
,
jsonParams
)
require
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
200
,
resp
.
StatusCode
,
"GET %q: status code"
,
resp
.
Request
.
URL
)
assert
.
Equal
(
t
,
expectedBody
,
string
(
body
),
"GET %q: response body"
,
resp
.
Request
.
URL
)
assert
.
Equal
(
t
,
archiveLength
,
len
(
body
),
"GET %q: body size"
,
resp
.
Request
.
URL
)
require
.
Equal
(
t
,
200
,
resp
.
StatusCode
,
"GET %q: status code"
,
resp
.
Request
.
URL
)
require
.
Equal
(
t
,
expectedBody
,
string
(
body
),
"GET %q: response body"
,
resp
.
Request
.
URL
)
require
.
Equal
(
t
,
archiveLength
,
len
(
body
),
"GET %q: body size"
,
resp
.
Request
.
URL
)
if
tc
.
cacheDisabled
{
_
,
err
:=
os
.
Stat
(
tc
.
archivePath
)
...
...
@@ -578,9 +577,9 @@ func TestGetSnapshotProxiedToGitalySuccessfully(t *testing.T) {
resp
,
body
,
err
:=
doSendDataRequest
(
"/api/v4/projects/:id/snapshot"
,
"git-snapshot"
,
params
)
require
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
http
.
StatusOK
,
resp
.
StatusCode
,
"GET %q: status code"
,
resp
.
Request
.
URL
)
assert
.
Equal
(
t
,
expectedBody
,
string
(
body
),
"GET %q: body"
,
resp
.
Request
.
URL
)
assert
.
Equal
(
t
,
archiveLength
,
len
(
body
),
"GET %q: body size"
,
resp
.
Request
.
URL
)
require
.
Equal
(
t
,
http
.
StatusOK
,
resp
.
StatusCode
,
"GET %q: status code"
,
resp
.
Request
.
URL
)
require
.
Equal
(
t
,
expectedBody
,
string
(
body
),
"GET %q: body"
,
resp
.
Request
.
URL
)
require
.
Equal
(
t
,
archiveLength
,
len
(
body
),
"GET %q: body size"
,
resp
.
Request
.
URL
)
testhelper
.
RequireResponseHeader
(
t
,
resp
,
"Content-Disposition"
,
`attachment; filename="snapshot.tar"`
)
testhelper
.
RequireResponseHeader
(
t
,
resp
,
"Content-Type"
,
"application/x-tar"
)
...
...
jobs_test.go
View file @
3701cc77
...
...
@@ -7,7 +7,7 @@ import (
"testing"
"time"
"github.com/stretchr/testify/
assert
"
"github.com/stretchr/testify/
require
"
)
func
startWorkhorseServerWithLongPolling
(
authBackend
string
,
pollingDuration
time
.
Duration
)
*
httptest
.
Server
{
...
...
@@ -33,7 +33,7 @@ func testJobsLongPolling(t *testing.T, pollingDuration time.Duration, requestJob
defer
ws
.
Close
()
resp
,
err
:=
requestJob
(
ws
.
URL
,
nil
)
assert
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
defer
resp
.
Body
.
Close
()
return
resp
...
...
@@ -41,12 +41,12 @@ func testJobsLongPolling(t *testing.T, pollingDuration time.Duration, requestJob
func
testJobsLongPollingEndpointDisabled
(
t
*
testing
.
T
,
requestJob
requestJobFunction
)
{
resp
:=
testJobsLongPolling
(
t
,
0
,
requestJob
)
assert
.
NotEqual
(
t
,
"yes"
,
resp
.
Header
.
Get
(
"Gitlab-Ci-Builds-Polling"
))
require
.
NotEqual
(
t
,
"yes"
,
resp
.
Header
.
Get
(
"Gitlab-Ci-Builds-Polling"
))
}
func
testJobsLongPollingEndpoint
(
t
*
testing
.
T
,
requestJob
requestJobFunction
)
{
resp
:=
testJobsLongPolling
(
t
,
time
.
Minute
,
requestJob
)
assert
.
Equal
(
t
,
"yes"
,
resp
.
Header
.
Get
(
"Gitlab-Ci-Builds-Polling"
))
require
.
Equal
(
t
,
"yes"
,
resp
.
Header
.
Get
(
"Gitlab-Ci-Builds-Polling"
))
}
func
TestJobsLongPollingEndpointDisabled
(
t
*
testing
.
T
)
{
...
...
main_test.go
View file @
3701cc77
This diff is collapsed.
Click to expand it.
upload_test.go
View file @
3701cc77
...
...
@@ -15,7 +15,6 @@ import (
"testing"
"github.com/dgrijalva/jwt-go"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/api"
...
...
@@ -49,10 +48,10 @@ func testArtifactsUpload(t *testing.T, uploadArtifacts uploadArtifactsFunction)
defer
ws
.
Close
()
resp
,
resource
,
err
:=
uploadArtifacts
(
ws
.
URL
,
contentType
,
reqBody
)
assert
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
defer
resp
.
Body
.
Close
()
assert
.
Equal
(
t
,
200
,
resp
.
StatusCode
,
"GET %q: expected 200, got %d"
,
resource
,
resp
.
StatusCode
)
require
.
Equal
(
t
,
200
,
resp
.
StatusCode
,
"GET %q: expected 200, got %d"
,
resource
,
resp
.
StatusCode
)
}
func
TestArtifactsUpload
(
t
*
testing
.
T
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment