From af0c1bf4ca3f6962e50b311f01bb2f8e7783f9d7 Mon Sep 17 00:00:00 2001 From: Marius Date: Sat, 12 Mar 2016 22:44:54 +0100 Subject: [PATCH] Add test for complete upload notifications --- patch_test.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/patch_test.go b/patch_test.go index a64ac5e..58fed54 100644 --- a/patch_test.go +++ b/patch_test.go @@ -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",