From acaaa10ff7fa19a1d27c5c79d62a5b1478103b0a Mon Sep 17 00:00:00 2001 From: Adam Jensen Date: Sat, 28 Apr 2018 15:39:40 -0400 Subject: [PATCH] Add POST tests --- post_test.go | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/post_test.go b/post_test.go index 639308d..53f88af 100644 --- a/post_test.go +++ b/post_test.go @@ -123,6 +123,54 @@ func TestPost(t *testing.T) { }).Run(handler, t) }) + SubTest(t, "UploadLengthAndUploadDeferLengthFail", func(t *testing.T, store *MockFullDataStore) { + handler, _ := NewHandler(Config{ + DataStore: store, + }) + + (&httpTest{ + Method: "POST", + URL: "", + ReqHeader: map[string]string{ + "Tus-Resumable": "1.0.0", + "Upload-Length": "10", + "Upload-Defer-Length": "1", + }, + Code: http.StatusBadRequest, + }).Run(handler, t) + }) + + SubTest(t, "NeitherUploadLengthNorUploadDeferLengthFail", func(t *testing.T, store *MockFullDataStore) { + handler, _ := NewHandler(Config{ + DataStore: store, + }) + + (&httpTest{ + Method: "POST", + URL: "", + ReqHeader: map[string]string{ + "Tus-Resumable": "1.0.0", + }, + Code: http.StatusBadRequest, + }).Run(handler, t) + }) + + SubTest(t, "InvalidUploadDeferLengthFail", func(t *testing.T, store *MockFullDataStore) { + handler, _ := NewHandler(Config{ + DataStore: store, + }) + + (&httpTest{ + Method: "POST", + URL: "", + ReqHeader: map[string]string{ + "Tus-Resumable": "1.0.0", + "Upload-Defer-Length": "bad", + }, + Code: http.StatusBadRequest, + }).Run(handler, t) + }) + SubTest(t, "ForwardHeaders", func(t *testing.T, store *MockFullDataStore) { SubTest(t, "IgnoreXForwarded", func(t *testing.T, store *MockFullDataStore) { store.EXPECT().NewUpload(FileInfo{