2015-12-25 21:33:27 +00:00
|
|
|
package tusd_test
|
2015-02-09 18:37:06 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"testing"
|
2015-12-25 21:33:27 +00:00
|
|
|
|
|
|
|
. "github.com/tus/tusd"
|
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{
|
2018-06-03 16:54:21 +00:00
|
|
|
"Tus-Extension": "creation,creation-with-upload",
|
2016-10-13 16:08:34 +00:00
|
|
|
"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
|
|
|
}
|