-
Notifications
You must be signed in to change notification settings - Fork 0
/
terminate_test.go
64 lines (55 loc) · 1.1 KB
/
terminate_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package tusd_test
import (
"net/http"
"testing"
. "github.com/tus/tusd"
)
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,termination",
},
Code: http.StatusNoContent,
}).Run(handler, t)
(&httpTest{
Name: "Successful request",
Method: "DELETE",
URL: "foo",
ReqHeader: map[string]string{
"Tus-Resumable": "1.0.0",
},
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)
}