-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtree_demo_test.go
93 lines (80 loc) · 1.7 KB
/
tree_demo_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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package brouter
import "testing"
func Test_demo_1(t *testing.T) {
tc := testCases{
{
insertPath: "/",
lookupPath: "/",
paramKey: []string{""},
paramValue: []string{""},
},
{
insertPath: "/hello/:name",
lookupPath: "/hello/guonaihong",
paramKey: []string{"name"},
paramValue: []string{"guonaihong"},
},
}
tc.run(t)
}
func Test_demo_2(t *testing.T) {
tc := testCases{
{
insertPath: "/authorizations",
lookupPath: "/authorizations",
paramKey: []string{""},
paramValue: []string{""},
},
}
tc.run(t)
}
func Test_demo_3(t *testing.T) {
tc := testCases{
{
insertPath: "/authorizations",
lookupPath: "/authorizations",
paramKey: []string{""},
paramValue: []string{""},
},
{
insertPath: "/authorizations/:id",
lookupPath: "/authorizations/hello",
paramKey: []string{"id"},
paramValue: []string{"hello"},
},
}
tc.run(t)
}
func Test_demo_4(t *testing.T) {
tc := testCases{
{
insertPath: "/authorizations/clients/:client_id",
lookupPath: "/authorizations/clients/guo_id",
paramKey: []string{"client_id"},
paramValue: []string{"guo_id"},
},
}
tc.run(t)
}
func Test_demo_5(t *testing.T) {
tc := testCases{
{
insertPath: "/applications/:client_id/tokens/:access_token",
lookupPath: "/applications/id/tokens/guonaihong_token",
paramKey: []string{"client_id", "access_token"},
paramValue: []string{"id", "guonaihong_token"},
},
}
tc.run(t)
}
func Test_demo_6(t *testing.T) {
tc := testCases{
{
insertPath: "/repos/:owner/:repo/events",
lookupPath: "/repos/guonaihong/brouter/events",
paramKey: []string{"owner", "repo"},
paramValue: []string{"guonaihong", "brouter"},
},
}
tc.run(t)
}