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