forked from yaitoo/xun
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpattern_test.go
More file actions
38 lines (29 loc) · 755 Bytes
/
pattern_test.go
File metadata and controls
38 lines (29 loc) · 755 Bytes
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 xun
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestPattern(t *testing.T) {
tests := []struct {
pattern string
method string
host string
path string
}{
{"", "", "", ""},
{"abc", "", "", "abc"},
{"/", "", "", ""},
{"/abc", "", "", "abc"},
{"GET /abc", "GET", "", "abc"},
{"GET /abc/", "GET", "", "abc/"},
{"GET abc.com/", "GET", "abc.com", ""},
{"GET abc.com/abc", "GET", "abc.com", "abc"},
{"GET abc.com/abc/", "GET", "abc.com", "abc/"},
}
for _, test := range tests {
method, host, path := splitPattern(test.pattern)
require.Equal(t, test.method, method, test.pattern)
require.Equal(t, test.host, host, test.pattern)
require.Equal(t, test.path, path, test.pattern)
}
}