2019-06-11 16:23:20 +00:00
|
|
|
package handler_test
|
2015-02-09 18:37:06 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"testing"
|
2015-12-25 21:33:27 +00:00
|
|
|
|
2019-06-11 16:23:20 +00:00
|
|
|
. "github.com/tus/tusd/pkg/handler"
|
2015-02-09 18:37:06 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestOptions(t *testing.T) {
|
2016-10-13 16:08:34 +00:00
|
|
|
SubTest(t, "Discovery", func(t *testing.T, store *MockFullDataStore) {
|
|
|
|
composer := NewStoreComposer()
|
|
|
|
composer.UseCore(store)
|
|
|
|
|
|
|
|
handler, _ := NewHandler(Config{
|
|
|
|
StoreComposer: composer,
|
|
|
|
MaxSize: 400,
|
|
|
|
})
|
|
|
|
|
|
|
|
(&httpTest{
|
|
|
|
Method: "OPTIONS",
|
|
|
|
ResHeader: map[string]string{
|
|
|
|
"Tus-Extension": "creation,creation-with-upload",
|
|
|
|
"Tus-Version": "1.0.0",
|
|
|
|
"Tus-Resumable": "1.0.0",
|
|
|
|
"Tus-Max-Size": "400",
|
|
|
|
},
|
|
|
|
Code: http.StatusOK,
|
|
|
|
}).Run(handler, t)
|
2015-02-09 18:37:06 +00:00
|
|
|
})
|
|
|
|
|
2016-10-13 16:08:34 +00:00
|
|
|
SubTest(t, "InvalidVersion", func(t *testing.T, store *MockFullDataStore) {
|
|
|
|
handler, _ := NewHandler(Config{
|
|
|
|
DataStore: store,
|
|
|
|
})
|
2015-02-09 18:37:06 +00:00
|
|
|
|
2016-10-13 16:08:34 +00:00
|
|
|
(&httpTest{
|
|
|
|
Method: "POST",
|
|
|
|
ReqHeader: map[string]string{
|
|
|
|
"Tus-Resumable": "foo",
|
|
|
|
},
|
|
|
|
Code: http.StatusPreconditionFailed,
|
|
|
|
}).Run(handler, t)
|
|
|
|
})
|
2015-02-09 18:37:06 +00:00
|
|
|
}
|