Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
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-workhorse
Commits
c290616d
Commit
c290616d
authored
Mar 29, 2017
by
Ahmad Sherif
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename testhelper.{AssertResponseHeader => AssertResponseWriterHeader}
parent
b4acd08e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
9 deletions
+19
-9
internal/artifacts/entry_test.go
internal/artifacts/entry_test.go
+2
-2
internal/git/archive_test.go
internal/git/archive_test.go
+4
-4
internal/staticpages/servefile_test.go
internal/staticpages/servefile_test.go
+2
-2
internal/testhelper/testhelper.go
internal/testhelper/testhelper.go
+11
-1
No files found.
internal/artifacts/entry_test.go
View file @
c290616d
...
...
@@ -57,10 +57,10 @@ func TestDownloadingFromValidArchive(t *testing.T) {
testhelper
.
AssertResponseCode
(
t
,
response
,
200
)
testhelper
.
AssertResponseHeader
(
t
,
response
,
testhelper
.
AssertResponse
Writer
Header
(
t
,
response
,
"Content-Type"
,
"text/plain; charset=utf-8"
)
testhelper
.
AssertResponseHeader
(
t
,
response
,
testhelper
.
AssertResponse
Writer
Header
(
t
,
response
,
"Content-Disposition"
,
"attachment; filename=
\"
test.txt
\"
"
)
...
...
internal/git/archive_test.go
View file @
c290616d
...
...
@@ -63,9 +63,9 @@ func TestSetArchiveHeaders(t *testing.T) {
setArchiveHeaders
(
w
,
testCase
.
in
,
"filename"
)
testhelper
.
AssertResponseHeader
(
t
,
w
,
"Content-Type"
,
testCase
.
out
)
testhelper
.
AssertResponseHeader
(
t
,
w
,
"Content-Length"
)
testhelper
.
AssertResponseHeader
(
t
,
w
,
"Content-Disposition"
,
`attachment; filename="filename"`
)
testhelper
.
AssertResponseHeader
(
t
,
w
,
"Cache-Control"
,
"private"
)
testhelper
.
AssertResponse
Writer
Header
(
t
,
w
,
"Content-Type"
,
testCase
.
out
)
testhelper
.
AssertResponse
Writer
Header
(
t
,
w
,
"Content-Length"
)
testhelper
.
AssertResponse
Writer
Header
(
t
,
w
,
"Content-Disposition"
,
`attachment; filename="filename"`
)
testhelper
.
AssertResponse
Writer
Header
(
t
,
w
,
"Cache-Control"
,
"private"
)
}
}
internal/staticpages/servefile_test.go
View file @
c290616d
...
...
@@ -110,13 +110,13 @@ func testServingThePregzippedFile(t *testing.T, enableGzip bool) {
st
.
ServeExisting
(
"/"
,
CacheDisabled
,
nil
)
.
ServeHTTP
(
w
,
httpRequest
)
testhelper
.
AssertResponseCode
(
t
,
w
,
200
)
if
enableGzip
{
testhelper
.
AssertResponseHeader
(
t
,
w
,
"Content-Encoding"
,
"gzip"
)
testhelper
.
AssertResponse
Writer
Header
(
t
,
w
,
"Content-Encoding"
,
"gzip"
)
if
bytes
.
Compare
(
w
.
Body
.
Bytes
(),
fileGzipContent
.
Bytes
())
!=
0
{
t
.
Error
(
"We should serve the pregzipped file"
)
}
}
else
{
testhelper
.
AssertResponseCode
(
t
,
w
,
200
)
testhelper
.
AssertResponseHeader
(
t
,
w
,
"Content-Encoding"
)
testhelper
.
AssertResponse
Writer
Header
(
t
,
w
,
"Content-Encoding"
)
if
w
.
Body
.
String
()
!=
fileContent
{
t
.
Error
(
"We should serve the file: "
,
w
.
Body
.
String
())
}
...
...
internal/testhelper/testhelper.go
View file @
c290616d
...
...
@@ -71,9 +71,19 @@ func AssertResponseBodyRegexp(t *testing.T, response *httptest.ResponseRecorder,
}
}
func
AssertResponseHeader
(
t
*
testing
.
T
,
w
http
.
ResponseWriter
,
header
string
,
expected
...
string
)
{
func
AssertResponse
Writer
Header
(
t
*
testing
.
T
,
w
http
.
ResponseWriter
,
header
string
,
expected
...
string
)
{
actual
:=
w
.
Header
()[
http
.
CanonicalHeaderKey
(
header
)]
assertHeaderExists
(
t
,
header
,
actual
,
expected
)
}
func
AssertResponseHeader
(
t
*
testing
.
T
,
w
*
http
.
Response
,
header
string
,
expected
...
string
)
{
actual
:=
w
.
Header
[
http
.
CanonicalHeaderKey
(
header
)]
assertHeaderExists
(
t
,
header
,
actual
,
expected
)
}
func
assertHeaderExists
(
t
*
testing
.
T
,
header
string
,
actual
,
expected
[]
string
)
{
if
len
(
expected
)
!=
len
(
actual
)
{
t
.
Fatalf
(
"for HTTP request expected to receive the header %q with %+v, got %+v"
,
header
,
expected
,
actual
)
}
...
...
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