blob: e622b7e781c81430aeba2dfdb89a7d43d476bdab (
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
|
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("/foo/:bar", "GET", testRequestRoute)
return router
}
func TestBasicRequest(t *testing.T) {
router := buildDispatcher()
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()
}
}
|