-
Notifications
You must be signed in to change notification settings - Fork 2
/
controller_test.go
53 lines (43 loc) · 1007 Bytes
/
controller_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
package carrot
import (
"testing"
)
func TestMethodInvocation(t *testing.T) {
_, _, req1, err := getTokenRouteAndRequestForTest(endpoint1)
if err != nil {
t.Error(err)
}
_, _, req2, err := getTokenRouteAndRequestForTest(endpoint2)
if err != nil {
t.Error(err)
}
_, _, req3, err := getTokenRouteAndRequestForTest(endpoint2)
if err != nil {
t.Error(err)
}
_, _, req4, err := getTokenRouteAndRequestForTest(endpoint2)
if err != nil {
t.Error(err)
}
d := NewDispatcher()
go d.Run()
d.requests <- req1
d.requests <- req2
d.requests <- req3
d.requests <- req4
}
func TestInvalidMethodInvocation(t *testing.T) {
_, _, req, err := getTokenRouteAndRequestForTest(endpoint3)
if err != nil {
t.Error(err)
}
rt, _ := Lookup(endpoint3)
c, err := NewController(rt.Controller(), false)
if err != nil {
t.Errorf("Failed to make controller")
}
err = c.Invoke(rt, req)
if err == nil {
t.Errorf("Method invocation did not capture invalid method and probably crashed.")
}
}