1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-03 18:27:07 +00:00

add the stale release

This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-08-12 23:41:20 +03:00
parent 535fb6dc0d
commit 2a4ce876b6
793 changed files with 188 additions and 52415 deletions

View File

@@ -3,9 +3,9 @@
package handler
import (
"github.com/kataras/iris/v12/context"
"github.com/kataras/iris/v12/core/memstore"
"github.com/kataras/iris/v12/macro"
"github.com/kataras/iris/context"
"github.com/kataras/iris/core/memstore"
"github.com/kataras/iris/macro"
)
// CanMakeHandler reports whether a macro template needs a special macro's evaluator handler to be validated

View File

@@ -1,41 +0,0 @@
package handler
import (
"testing"
"github.com/kataras/iris/v12/macro"
)
func TestCanMakeHandler(t *testing.T) {
tests := []struct {
src string
needsHandler bool
}{
{"/static/static", false},
{"/{myparam}", false},
{"/{myparam min(1)}", true},
{"/{myparam else 500}", true},
{"/{myparam else 404}", false},
{"/{myparam:string}/static", false},
{"/{myparam:int}", true},
{"/static/{myparam:int}/static", true},
{"/{myparam:path}", false},
{"/{myparam:path min(1) else 404}", true},
}
availableMacros := *macro.Defaults
for i, tt := range tests {
tmpl, err := macro.Parse(tt.src, availableMacros)
if err != nil {
t.Fatalf("[%d] '%s' failed to be parsed: %v", i, tt.src, err)
}
if got := CanMakeHandler(tmpl); got != tt.needsHandler {
if tt.needsHandler {
t.Fatalf("[%d] '%s' expected to be able to generate an evaluator handler instead of a nil one", i, tt.src)
} else {
t.Fatalf("[%d] '%s' should not need an evaluator handler", i, tt.src)
}
}
}
}