diff --git a/concat_test.go b/concat_test.go index 8a06c13..11d6e20 100644 --- a/concat_test.go +++ b/concat_test.go @@ -126,14 +126,20 @@ func (s concatFinalStore) ConcatUploads(id string, uploads []string) error { } func TestConcatFinal(t *testing.T) { + a := assert.New(t) + handler, _ := NewHandler(Config{ MaxSize: 400, BasePath: "files", DataStore: concatFinalStore{ - t: assert.New(t), + t: a, }, + NotifyCompleteUploads: true, }) + c := make(chan FileInfo, 1) + handler.CompleteUploads = c + (&httpTest{ Name: "Successful POST request", Method: "POST", @@ -144,6 +150,14 @@ func TestConcatFinal(t *testing.T) { Code: http.StatusCreated, }).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{ Name: "Successful HEAD request", Method: "HEAD", diff --git a/unrouted_handler.go b/unrouted_handler.go index da60c55..3303a8a 100644 --- a/unrouted_handler.go +++ b/unrouted_handler.go @@ -238,6 +238,7 @@ func (handler *UnroutedHandler) PostFile(w http.ResponseWriter, r *http.Request) handler.sendError(w, r, err) return } + info.Offset = size if handler.config.NotifyCompleteUploads { info.ID = id