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
0af84341
Commit
0af84341
authored
Apr 19, 2017
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make 'code' argument saner
parent
e54d68d3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
10 deletions
+22
-10
gitaly_test.go
gitaly_test.go
+2
-2
internal/testhelper/gitaly.go
internal/testhelper/gitaly.go
+20
-8
No files found.
gitaly_test.go
View file @
0af84341
...
...
@@ -199,13 +199,13 @@ func TestPostUploadPackHandledLocallyDueToEmptyGitalySocketPath(t *testing.T) {
testhelper
.
AssertResponseHeader
(
t
,
resp
,
"Content-Type"
,
"application/x-git-upload-pack-result"
)
}
func
startGitalyServer
(
t
*
testing
.
T
,
c
ode
codes
.
Code
)
(
*
grpc
.
Server
,
string
)
{
func
startGitalyServer
(
t
*
testing
.
T
,
finalMessageC
ode
codes
.
Code
)
(
*
grpc
.
Server
,
string
)
{
socketPath
:=
path
.
Join
(
scratchDir
,
fmt
.
Sprintf
(
"gitaly-%d.sock"
,
rand
.
Int
()))
server
:=
grpc
.
NewServer
()
listener
,
err
:=
net
.
Listen
(
"unix"
,
socketPath
)
require
.
NoError
(
t
,
err
)
pb
.
RegisterSmartHTTPServer
(
server
,
testhelper
.
NewGitalyServer
(
c
ode
))
pb
.
RegisterSmartHTTPServer
(
server
,
testhelper
.
NewGitalyServer
(
finalMessageC
ode
))
go
server
.
Serve
(
listener
)
...
...
internal/testhelper/gitaly.go
View file @
0af84341
...
...
@@ -15,7 +15,7 @@ import (
)
type
GitalyTestServer
struct
{
c
ode
codes
.
Code
finalMessageC
ode
codes
.
Code
}
const
GitalyInfoRefsResponseMock
=
"Mock Gitaly InfoRefsResponse data"
...
...
@@ -33,8 +33,8 @@ func init() {
}
}
func
NewGitalyServer
(
c
ode
codes
.
Code
)
*
GitalyTestServer
{
return
&
GitalyTestServer
{
code
:
c
ode
}
func
NewGitalyServer
(
finalMessageC
ode
codes
.
Code
)
*
GitalyTestServer
{
return
&
GitalyTestServer
{
finalMessageCode
:
finalMessageC
ode
}
}
func
(
s
*
GitalyTestServer
)
InfoRefsUploadPack
(
in
*
pb
.
InfoRefsRequest
,
stream
pb
.
SmartHTTP_InfoRefsUploadPackServer
)
error
{
...
...
@@ -45,7 +45,11 @@ func (s *GitalyTestServer) InfoRefsUploadPack(in *pb.InfoRefsRequest, stream pb.
response
:=
&
pb
.
InfoRefsResponse
{
Data
:
[]
byte
(
GitalyInfoRefsResponseMock
),
}
return
stream
.
Send
(
response
)
if
err
:=
stream
.
Send
(
response
);
err
!=
nil
{
return
err
}
return
s
.
finalError
()
}
func
(
s
*
GitalyTestServer
)
InfoRefsReceivePack
(
in
*
pb
.
InfoRefsRequest
,
stream
pb
.
SmartHTTP_InfoRefsReceivePackServer
)
error
{
...
...
@@ -56,7 +60,11 @@ func (s *GitalyTestServer) InfoRefsReceivePack(in *pb.InfoRefsRequest, stream pb
response
:=
&
pb
.
InfoRefsResponse
{
Data
:
[]
byte
(
GitalyInfoRefsResponseMock
),
}
return
stream
.
Send
(
response
)
if
err
:=
stream
.
Send
(
response
);
err
!=
nil
{
return
err
}
return
s
.
finalError
()
}
func
(
s
*
GitalyTestServer
)
PostReceivePack
(
stream
pb
.
SmartHTTP_PostReceivePackServer
)
error
{
...
...
@@ -99,7 +107,7 @@ func (s *GitalyTestServer) PostReceivePack(stream pb.SmartHTTP_PostReceivePackSe
}
}
return
nil
return
s
.
finalError
()
}
func
(
s
*
GitalyTestServer
)
PostUploadPack
(
stream
pb
.
SmartHTTP_PostUploadPackServer
)
error
{
...
...
@@ -141,8 +149,12 @@ func (s *GitalyTestServer) PostUploadPack(stream pb.SmartHTTP_PostUploadPackServ
}
}
if
s
.
code
!=
codes
.
OK
{
return
grpc
.
Errorf
(
s
.
code
,
"error as specified by test"
)
return
s
.
finalError
()
}
func
(
s
*
GitalyTestServer
)
finalError
()
error
{
if
code
:=
s
.
finalMessageCode
;
code
!=
codes
.
OK
{
return
grpc
.
Errorf
(
code
,
"error as specified by test"
)
}
return
nil
...
...
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