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
12dacc74
Commit
12dacc74
authored
Apr 05, 2018
by
Alessio Caiazza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify Uploads test
parent
6fba18f6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
14 deletions
+16
-14
internal/upload/uploads_test.go
internal/upload/uploads_test.go
+16
-14
No files found.
internal/upload/uploads_test.go
View file @
12dacc74
...
...
@@ -20,6 +20,7 @@ import (
"gitlab.com/gitlab-org/gitlab-workhorse/internal/badgateway"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/filestore"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/objectstore/test"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/proxy"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/testhelper"
)
...
...
@@ -29,9 +30,6 @@ var nilHandler = http.HandlerFunc(func(http.ResponseWriter, *http.Request) {})
type
testFormProcessor
struct
{}
func
(
a
*
testFormProcessor
)
ProcessFile
(
ctx
context
.
Context
,
formName
string
,
file
*
filestore
.
FileHandler
,
writer
*
multipart
.
Writer
)
error
{
if
formName
!=
"file"
&&
file
.
LocalPath
!=
"my.file"
{
return
errors
.
New
(
"illegal file"
)
}
return
nil
}
...
...
@@ -233,15 +231,10 @@ func TestUploadProcessingFile(t *testing.T) {
}
defer
os
.
RemoveAll
(
tempPath
)
var
buffer
bytes
.
Buffer
_
,
testServer
:=
test
.
StartObjectStore
()
defer
testServer
.
Close
()
writer
:=
multipart
.
NewWriter
(
&
buffer
)
file
,
err
:=
writer
.
CreateFormFile
(
"file2"
,
"my.file"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
fmt
.
Fprint
(
file
,
"test"
)
writer
.
Close
()
storeUrl
:=
testServer
.
URL
+
test
.
ObjectPath
tests
:=
[]
struct
{
name
string
...
...
@@ -253,19 +246,28 @@ func TestUploadProcessingFile(t *testing.T) {
},
{
name
:
"ObjectStore Upload"
,
preauth
:
api
.
Response
{
RemoteObject
:
api
.
RemoteObject
{
StoreURL
:
"http://example.com"
}},
preauth
:
api
.
Response
{
RemoteObject
:
api
.
RemoteObject
{
StoreURL
:
storeUrl
}},
},
{
name
:
"ObjectStore and FileStore Upload"
,
preauth
:
api
.
Response
{
TempPath
:
tempPath
,
RemoteObject
:
api
.
RemoteObject
{
StoreURL
:
"http://example.com"
},
RemoteObject
:
api
.
RemoteObject
{
StoreURL
:
storeUrl
},
},
},
}
for
_
,
test
:=
range
tests
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
var
buffer
bytes
.
Buffer
writer
:=
multipart
.
NewWriter
(
&
buffer
)
file
,
err
:=
writer
.
CreateFormFile
(
"file"
,
"my.file"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
fmt
.
Fprint
(
file
,
"test"
)
writer
.
Close
()
httpRequest
,
err
:=
http
.
NewRequest
(
"PUT"
,
"/url/path"
,
&
buffer
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
...
...
@@ -274,7 +276,7 @@ func TestUploadProcessingFile(t *testing.T) {
response
:=
httptest
.
NewRecorder
()
HandleFileUploads
(
response
,
httpRequest
,
nilHandler
,
&
test
.
preauth
,
&
testFormProcessor
{})
testhelper
.
AssertResponseCode
(
t
,
response
,
5
00
)
testhelper
.
AssertResponseCode
(
t
,
response
,
2
00
)
})
}
...
...
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