-
Notifications
You must be signed in to change notification settings - Fork 8
/
resource_test.go
52 lines (46 loc) · 1.4 KB
/
resource_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
package yarf
import (
"net/http"
"net/http/httptest"
"testing"
)
func TestResourceInterface(t *testing.T) {
var r interface{}
r = new(Resource)
if _, ok := r.(ResourceHandler); !ok {
t.Error("Resource type doesn't implement ResourceHandler interface")
}
}
func TestResourceInterfaceMethods(t *testing.T) {
r := new(Resource)
req, _ := http.NewRequest("GET", "http://localhost:8080/test", nil)
res := httptest.NewRecorder()
c := NewContext(req, res)
if r.Get(c) == nil {
t.Error("Get() should return a MethodNotImplementedError type by default.")
}
if r.Post(c) == nil {
t.Error("Post() should return a MethodNotImplementedError type by default.")
}
if r.Put(c) == nil {
t.Error("Put() should return a MethodNotImplementedError type by default.")
}
if r.Delete(c) == nil {
t.Error("Delete() should return a MethodNotImplementedError type by default.")
}
if r.Patch(c) == nil {
t.Error("Patch() should return a MethodNotImplementedError type by default.")
}
if r.Head(c) == nil {
t.Error("Head() should return a MethodNotImplementedError type by default.")
}
if r.Options(c) == nil {
t.Error("Options() should return a MethodNotImplementedError type by default.")
}
if r.Connect(c) == nil {
t.Error("Connect() should return a MethodNotImplementedError type by default.")
}
if r.Trace(c) == nil {
t.Error("Trace() should return a MethodNotImplementedError type by default.")
}
}