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
0
Merge Requests
0
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
Kazuhiko Shiozaki
gitlab-workhorse
Commits
b6dcb7c8
Commit
b6dcb7c8
authored
Feb 01, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for sending Git blobs
parent
90d98776
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
main_test.go
main_test.go
+38
-0
No files found.
main_test.go
View file @
b6dcb7c8
...
@@ -555,6 +555,44 @@ func TestArtifactsGetSingleFile(t *testing.T) {
...
@@ -555,6 +555,44 @@ func TestArtifactsGetSingleFile(t *testing.T) {
}
}
}
}
func
TestGetGitBlob
(
t
*
testing
.
T
)
{
blobId
:=
"50b27c6518be44c42c4d87966ae2481ce895624c"
// the LICENSE file in the test repository
blobLength
:=
1075
ts
:=
testhelper
.
TestServerWithHandler
(
regexp
.
MustCompile
(
`.`
),
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
responseJSON
:=
fmt
.
Sprintf
(
`{"RepoPath":"%s","BlobId":"%s"}`
,
path
.
Join
(
testRepoRoot
,
testRepo
),
blobId
)
encodedJSON
:=
base64
.
StdEncoding
.
EncodeToString
([]
byte
(
responseJSON
))
w
.
Header
()
.
Set
(
"Gitlab-Workhorse-Send-Data"
,
"git-blob:"
+
encodedJSON
)
// Prevent the Go HTTP server from setting the Content-Length to 0.
w
.
Header
()
.
Set
(
"Transfer-Encoding"
,
"chunked"
)
if
_
,
err
:=
fmt
.
Fprintf
(
w
,
"GNU General Public License"
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
return
})
defer
ts
.
Close
()
ws
:=
startWorkhorseServer
(
ts
.
URL
)
defer
ws
.
Close
()
resourcePath
:=
"/something"
resp
,
err
:=
http
.
Get
(
ws
.
URL
+
resourcePath
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
defer
resp
.
Body
.
Close
()
if
resp
.
StatusCode
!=
200
{
t
.
Errorf
(
"GET %q: expected 200, got %d"
,
resourcePath
,
resp
.
StatusCode
)
}
body
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
len
(
body
)
!=
blobLength
{
t
.
Fatalf
(
"Expected body of %d bytes, got %d"
,
blobLength
,
len
(
body
))
}
if
!
strings
.
HasPrefix
(
string
(
body
),
"The MIT License (MIT)"
)
{
t
.
Fatalf
(
"Expected MIT license, got %q"
,
body
)
}
}
func
setupStaticFile
(
fpath
,
content
string
)
error
{
func
setupStaticFile
(
fpath
,
content
string
)
error
{
cwd
,
err
:=
os
.
Getwd
()
cwd
,
err
:=
os
.
Getwd
()
if
err
!=
nil
{
if
err
!=
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