tusd/options_test.go

46 lines
910 B
Go
Raw Permalink Normal View History

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) {
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
})
SubTest(t, "InvalidVersion", func(t *testing.T, store *MockFullDataStore) {
handler, _ := NewHandler(Config{
DataStore: store,
})
2015-02-09 18:37:06 +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
}