Add test for complete upload notifications

This commit is contained in:
Marius 2016-03-12 22:44:54 +01:00
parent acf2e8daee
commit af0c1bf4ca
1 changed files with 14 additions and 2 deletions

View File

@ -25,8 +25,9 @@ func (s patchStore) GetInfo(id string) (FileInfo, error) {
}
return FileInfo{
ID: id,
Offset: 5,
Size: 20,
Size: 10,
}, nil
}
@ -44,13 +45,19 @@ func (s patchStore) WriteChunk(id string, offset int64, src io.Reader) (int64, e
}
func TestPatch(t *testing.T) {
a := assert.New(t)
handler, _ := NewHandler(Config{
MaxSize: 100,
DataStore: patchStore{
t: assert.New(t),
t: a,
},
NotifyCompleteUploads: true,
})
c := make(chan FileInfo, 1)
handler.CompleteUploads = c
(&httpTest{
Name: "Successful request",
Method: "PATCH",
@ -67,6 +74,11 @@ func TestPatch(t *testing.T) {
},
}).Run(handler, t)
info := <-c
a.Equal("yes", info.ID)
a.Equal(int64(10), info.Size)
a.Equal(int64(10), info.Offset)
(&httpTest{
Name: "Non-existing file",
Method: "PATCH",