tusd/options_test.go

39 lines
756 B
Go
Raw 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) {
2016-03-11 19:46:34 +00:00
store := NewStoreComposer()
store.UseCore(NewMockFullDataStore(nil))
2015-02-09 18:37:06 +00:00
handler, _ := NewHandler(Config{
2016-03-11 19:46:34 +00:00
StoreComposer: store,
MaxSize: 400,
2015-02-09 18:37:06 +00:00
})
2015-02-17 14:44:12 +00:00
(&httpTest{
Name: "Successful request",
Method: "OPTIONS",
Code: http.StatusOK,
2015-02-17 14:44:12 +00:00
ResHeader: map[string]string{
"Tus-Extension": "creation,creation-with-upload",
2015-03-23 17:15:05 +00:00
"Tus-Version": "1.0.0",
"Tus-Resumable": "1.0.0",
"Tus-Max-Size": "400",
2015-02-17 14:44:12 +00:00
},
}).Run(handler, t)
2015-02-09 18:37:06 +00:00
2015-02-17 14:44:12 +00:00
(&httpTest{
Name: "Invalid or unsupported version",
Method: "POST",
ReqHeader: map[string]string{
2015-03-23 17:15:05 +00:00
"Tus-Resumable": "foo",
2015-02-17 14:44:12 +00:00
},
Code: http.StatusPreconditionFailed,
}).Run(handler, t)
2015-02-09 18:37:06 +00:00
}