-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtree_test.go
39 lines (34 loc) · 883 Bytes
/
tree_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
package goose
import (
"net/http"
"testing"
)
func TestAsteroidRouting(t *testing.T) {
signature := ""
g := New()
g.GET("/assets/*files", func(ctx *Context) {
signature += ctx.Param("files")
})
// test /assets/hello
signature = ""
w := sendRequest(g, http.MethodGet, "/assets/hello")
if w.Code != http.StatusOK {
t.Errorf("Got status code %d instead of 200.", w.Code)
}
want := "hello"
got := signature
if got != want {
t.Errorf("Want: %s , Got: %s", want, got)
}
// test /assets/this/is/path/to/static/files/like/hello.js
signature = ""
w = sendRequest(g, http.MethodGet, "/assets/this/is/path/to/static/files/like/hello.js")
if w.Code != http.StatusOK {
t.Errorf("Got status code %d instead of 200.", w.Code)
}
want = "this/is/path/to/static/files/like/hello.js"
got = signature
if got != want {
t.Errorf("Want: %s , Got: %s", want, got)
}
}