tusd/terminate_test.go

65 lines
1.1 KiB
Go
Raw Normal View History

2015-12-25 21:33:27 +00:00
package tusd_test
2015-02-28 13:47:39 +00:00
import (
"net/http"
"testing"
2015-12-25 21:33:27 +00:00
. "github.com/tus/tusd"
2015-02-28 13:47:39 +00:00
)
type terminateStore struct {
t *testing.T
zeroStore
}
func (s terminateStore) Terminate(id string) error {
if id != "foo" {
s.t.Fatal("unexpected id")
}
return nil
}
func TestTerminate(t *testing.T) {
handler, _ := NewHandler(Config{
DataStore: terminateStore{
t: t,
},
})
(&httpTest{
Name: "Successful OPTIONS request",
Method: "OPTIONS",
URL: "",
ResHeader: map[string]string{
"Tus-Extension": "creation,concatenation,termination",
},
Code: http.StatusNoContent,
}).Run(handler, t)
2015-02-28 13:47:39 +00:00
(&httpTest{
Name: "Successful request",
Method: "DELETE",
URL: "foo",
ReqHeader: map[string]string{
2015-03-23 17:15:05 +00:00
"Tus-Resumable": "1.0.0",
2015-02-28 13:47:39 +00:00
},
Code: http.StatusNoContent,
}).Run(handler, t)
}
func TestTerminateNotImplemented(t *testing.T) {
handler, _ := NewHandler(Config{
DataStore: zeroStore{},
})
(&httpTest{
Name: "TerminaterDataStore not implemented",
Method: "DELETE",
URL: "foo",
ReqHeader: map[string]string{
"Tus-Resumable": "1.0.0",
},
Code: http.StatusMethodNotAllowed,
}).Run(handler, t)
}