Add POST tests
@@ -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{
