Add test for complete upload notifications using Concatenaiton

This commit is contained in:
Marius 2016-03-12 22:52:31 +01:00
parent af0c1bf4ca
commit bcea96b88e
2 changed files with 16 additions and 1 deletions

View File

@ -126,14 +126,20 @@ func (s concatFinalStore) ConcatUploads(id string, uploads []string) error {
} }
func TestConcatFinal(t *testing.T) { func TestConcatFinal(t *testing.T) {
a := assert.New(t)
handler, _ := NewHandler(Config{ handler, _ := NewHandler(Config{
MaxSize: 400, MaxSize: 400,
BasePath: "files", BasePath: "files",
DataStore: concatFinalStore{ DataStore: concatFinalStore{
t: assert.New(t), t: a,
}, },
NotifyCompleteUploads: true,
}) })
c := make(chan FileInfo, 1)
handler.CompleteUploads = c
(&httpTest{ (&httpTest{
Name: "Successful POST request", Name: "Successful POST request",
Method: "POST", Method: "POST",
@ -144,6 +150,14 @@ func TestConcatFinal(t *testing.T) {
Code: http.StatusCreated, Code: http.StatusCreated,
}).Run(handler, t) }).Run(handler, t)
info := <-c
a.Equal("foo", info.ID)
a.Equal(int64(10), info.Size)
a.Equal(int64(10), info.Offset)
a.False(info.IsPartial)
a.True(info.IsFinal)
a.Equal([]string{"a", "b"}, info.PartialUploads)
(&httpTest{ (&httpTest{
Name: "Successful HEAD request", Name: "Successful HEAD request",
Method: "HEAD", Method: "HEAD",

View File

@ -238,6 +238,7 @@ func (handler *UnroutedHandler) PostFile(w http.ResponseWriter, r *http.Request)
handler.sendError(w, r, err) handler.sendError(w, r, err)
return return
} }
info.Offset = size
if handler.config.NotifyCompleteUploads { if handler.config.NotifyCompleteUploads {
info.ID = id info.ID = id