tusd/pkg/handler/options_test.go

46 lines
981 B
Go
Raw Normal View History

package handler_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/pkg/handler"
2015-02-09 18:37:06 +00:00
)
func TestOptions(t *testing.T) {
SubTest(t, "Discovery", func(t *testing.T, store *MockFullDataStore, composer *StoreComposer) {
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, composer *StoreComposer) {
handler, _ := NewHandler(Config{
StoreComposer: composer,
})
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
}