mirror of
https://github.com/kataras/iris.git
synced 2026-01-06 03:27:27 +00:00
create the new FileServer and HandleDir, deprecate the rest APIBuilder/Party static methods and more
relative: https://github.com/kataras/iris/issues/1283 and removing pongo2 from vendor: https://github.com/kataras/iris/issues/1284 Former-commit-id: 3ec57b349f99faca2b8e36d9f7252db0b6ea080d
This commit is contained in:
56
core/router/route_test.go
Normal file
56
core/router/route_test.go
Normal file
@@ -0,0 +1,56 @@
|
||||
// white-box testing
|
||||
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris/macro"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRouteStaticPath(t *testing.T) {
|
||||
var 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user