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
d334c549
Commit
d334c549
authored
Mar 03, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use custom usptreamResponseCode
parent
58ceb231
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
internal/builds/register_test.go
internal/builds/register_test.go
+8
-5
No files found.
internal/builds/register_test.go
View file @
d334c549
...
@@ -14,7 +14,10 @@ import (
...
@@ -14,7 +14,10 @@ import (
"gitlab.com/gitlab-org/gitlab-workhorse/internal/redis"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/redis"
)
)
const
upstreamResponseCode
=
999
func
echoRequest
(
rw
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
func
echoRequest
(
rw
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
rw
.
WriteHeader
(
upstreamResponseCode
)
io
.
Copy
(
rw
,
req
.
Body
)
io
.
Copy
(
rw
,
req
.
Body
)
}
}
...
@@ -43,12 +46,12 @@ func TestRegisterHandlerLargeBody(t *testing.T) {
...
@@ -43,12 +46,12 @@ func TestRegisterHandlerLargeBody(t *testing.T) {
}
}
func
TestRegisterHandlerInvalidRunnerRequest
(
t
*
testing
.
T
)
{
func
TestRegisterHandlerInvalidRunnerRequest
(
t
*
testing
.
T
)
{
expectHandler
(
t
,
"invalid content"
,
"text/plain"
,
http
.
StatusOK
,
expectHandler
(
t
,
"invalid content"
,
"text/plain"
,
upstreamResponseCode
,
"proxies request to upstream"
)
"proxies request to upstream"
)
}
}
func
TestRegisterHandlerInvalidJsonPayload
(
t
*
testing
.
T
)
{
func
TestRegisterHandlerInvalidJsonPayload
(
t
*
testing
.
T
)
{
expectHandler
(
t
,
`{[`
,
"application/json"
,
http
.
StatusOK
,
expectHandler
(
t
,
`{[`
,
"application/json"
,
upstreamResponseCode
,
"fails on parsing body and proxies request to upstream"
)
"fails on parsing body and proxies request to upstream"
)
}
}
...
@@ -59,7 +62,7 @@ func TestRegisterHandlerMissingData(t *testing.T) {
...
@@ -59,7 +62,7 @@ func TestRegisterHandlerMissingData(t *testing.T) {
}
}
for
_
,
testCase
:=
range
testCases
{
for
_
,
testCase
:=
range
testCases
{
expectHandler
(
t
,
testCase
,
"application/json"
,
http
.
StatusOK
,
expectHandler
(
t
,
testCase
,
"application/json"
,
upstreamResponseCode
,
"fails on argument validation and proxies request to upstream"
)
"fails on argument validation and proxies request to upstream"
)
}
}
}
}
...
@@ -80,12 +83,12 @@ func expectWatcherToBeExecuted(t *testing.T, watchKeyStatus redis.WatchKeyStatus
...
@@ -80,12 +83,12 @@ func expectWatcherToBeExecuted(t *testing.T, watchKeyStatus redis.WatchKeyStatus
func
TestRegisterHandlerWatcherError
(
t
*
testing
.
T
)
{
func
TestRegisterHandlerWatcherError
(
t
*
testing
.
T
)
{
expectWatcherToBeExecuted
(
t
,
redis
.
WatchKeyStatusNoChange
,
errors
.
New
(
"redis connection"
),
expectWatcherToBeExecuted
(
t
,
redis
.
WatchKeyStatusNoChange
,
errors
.
New
(
"redis connection"
),
http
.
StatusOK
,
"proxies data to upstream"
)
upstreamResponseCode
,
"proxies data to upstream"
)
}
}
func
TestRegisterHandlerWatcherAlreadyChanged
(
t
*
testing
.
T
)
{
func
TestRegisterHandlerWatcherAlreadyChanged
(
t
*
testing
.
T
)
{
expectWatcherToBeExecuted
(
t
,
redis
.
WatchKeyStatusAlreadyChanged
,
nil
,
expectWatcherToBeExecuted
(
t
,
redis
.
WatchKeyStatusAlreadyChanged
,
nil
,
http
.
StatusOK
,
"proxies data to upstream"
)
upstreamResponseCode
,
"proxies data to upstream"
)
}
}
func
TestRegisterHandlerWatcherSeenChange
(
t
*
testing
.
T
)
{
func
TestRegisterHandlerWatcherSeenChange
(
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