-
Notifications
You must be signed in to change notification settings - Fork 1
/
group_test.go
38 lines (34 loc) · 796 Bytes
/
group_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
package zoox
import "testing"
func TestGroupMatchPath(t *testing.T) {
testcases := []map[string]any{
{
"path": "/",
"prefix": "/",
"expect": true,
},
{
"path": "/",
"prefix": "/api",
"expect": false,
},
{
"path": "/api",
"prefix": "/",
"expect": true,
},
{
"path": "/v1/containers/d0ac6213f33620362e59cc1b855658f9792377335087c2f3ba1d43639466dd8a/terminal",
"prefix": "/v1/containers/:id",
"expect": true,
},
}
for _, testcase := range testcases {
group := &RouterGroup{
prefix: testcase["prefix"].(string),
}
if got := group.matchPath(testcase["path"].(string)); got != testcase["expect"] {
t.Fatalf("expected %v, got %v (path: %s, group: %s)", testcase["expect"], got, testcase["path"], testcase["prefix"])
}
}
}