mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 18:51:03 +01:00
07046ab978
Former-commit-id: 037081db5d6d4434e873ca8b75334ee43e046b6a
57 lines
928 B
Go
57 lines
928 B
Go
// white-box testing
|
|
|
|
package router
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/kataras/iris/macro"
|
|
)
|
|
|
|
func TestRouteStaticPath(t *testing.T) {
|
|
tests := []struct {
|
|
tmpl string
|
|
static string
|
|
}{
|
|
{
|
|
tmpl: "/files/{file:path}",
|
|
static: "/files",
|
|
},
|
|
{
|
|
tmpl: "/path",
|
|
static: "/path",
|
|
},
|
|
{
|
|
tmpl: "/path/segment",
|
|
static: "/path/segment",
|
|
},
|
|
{
|
|
tmpl: "/path/segment/{n:int}",
|
|
static: "/path/segment",
|
|
},
|
|
{
|
|
tmpl: "/path/{n:uint64}/{n:int}",
|
|
static: "/path",
|
|
},
|
|
{
|
|
tmpl: "/path/{n:uint64}/static",
|
|
static: "/path",
|
|
},
|
|
{
|
|
tmpl: "/{name}",
|
|
static: "/",
|
|
},
|
|
{
|
|
tmpl: "/",
|
|
static: "/",
|
|
},
|
|
}
|
|
|
|
for i, tt := range tests {
|
|
route := Route{tmpl: macro.Template{Src: tt.tmpl}}
|
|
if expected, got := tt.static, route.StaticPath(); expected != got {
|
|
t.Fatalf("[%d:%s] expected static path to be: '%s' but got: '%s'", i, tt.tmpl, expected, got)
|
|
}
|
|
}
|
|
}
|