blob: a9826ba53e52dcc7fd0ab5c0da738605f93277b4 (
plain) (
blame)
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
|
package mooh
import (
"testing"
)
func testRouter (req *Request) (Response, error) {
resp := Response{}
return resp, nil
}
func testBasic(t *testing.T) {
d := BuildRouter()
err := d.AddRoute(&Route{Method:"GET", Path:"/", Code: testRouter})
if err != nil {
t.Fatal()
}
err = d.AddRoute(&Route{Method: "GET", Path:"/", Code: testRouter})
if err == nil {
t.Fatal()
}
}
func TestGetRouteList(t *testing.T) {
r := BuildRouter()
r.AddRoute(&Route{Method: "GET", Path: "/foo", Code: testRoute})
r.AddRoute(&Route{Method: "GET", Path: "/bar", Code: testRoute})
r.AddRoute(&Route{Method: "GET", Path: "/baz", Code: testRoute})
routes := r.GetRouteList()
if len(routes) != 3 {
t.Fatal()
}
if routes[0] != "/foo" {
t.Fatal()
}
}
|