blob: 715baaeb9b2b6ca78ab65b2e52638dd5fc86d46a (
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
|
package mooh
import (
"net/http"
"net/url"
"testing"
)
func testRequestRoute(req *Request) (Response, error) {
resp := Response{}
return resp, nil
}
func buildDispatcher() Dispatcher {
router := BuildDispatcher()
router.AddRoute(&Route{Method: "GET", Path: "/foo/:bar", Code: testRequestRoute})
return router
}
func TestBasicRequest(t *testing.T) {
router := buildDispatcher()
t.Log(router.routes[0].components)
r := &http.Request{Method: "GET", URL: &url.URL{Path: "/foo/bar"}}
m, _ := router.Match(r)
request := NewRequest(r, m)
if request == nil {
t.Fatal()
}
if p := request.RouteParam("bar"); p != "bar" {
t.Fatal()
}
}
|