mirror of
https://github.com/kataras/iris.git
synced 2025-12-20 03:17:04 +00:00
Former-commit-id: 5ade70e6133406c8bbb4ecef36541fdd0d857f6f
This commit is contained in:
@@ -4,6 +4,44 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSplitPath(t *testing.T) {
|
||||
tests := []struct {
|
||||
path string
|
||||
expected []string
|
||||
}{
|
||||
{"/v2/stores/{id:string format(uuid)} /v3",
|
||||
[]string{"/v2/stores/{id:string format(uuid)}", "/v3"}},
|
||||
{"/user/{id:int} /admin/{id:int}",
|
||||
[]string{"/user/{id:int}", "/admin/{id:int}"}},
|
||||
{"/user /admin",
|
||||
[]string{"/user", "/admin"}},
|
||||
{"/single_no_params",
|
||||
[]string{"/single_no_params"}},
|
||||
{"/single/{id:int}",
|
||||
[]string{"/single/{id:int}"}},
|
||||
}
|
||||
|
||||
equalSlice := func(s1 []string, s2 []string) bool {
|
||||
if len(s1) != len(s2) {
|
||||
return false
|
||||
}
|
||||
|
||||
for i := range s1 {
|
||||
if s2[i] != s1[i] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
for i, tt := range tests {
|
||||
paths := splitPath(tt.path)
|
||||
if expected, got := tt.expected, paths; !equalSlice(expected, got) {
|
||||
t.Fatalf("[%d] - expected paths '%#v' but got '%#v'", i, expected, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
func TestSplitSubdomainAndPath(t *testing.T) {
|
||||
tests := []struct {
|
||||
original string
|
||||
|
||||
Reference in New Issue
Block a user