Add test for complete upload notifications using Concatenaiton
This commit is contained in:
parent
af0c1bf4ca
commit
bcea96b88e
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue