MCPcopy Create free account
hub / github.com/kataras/iris / TestCanMakeHandler

Function TestCanMakeHandler

macro/handler/handler_test.go:9–41  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestCanMakeHandler(t *testing.T) {
10 tests := []struct {
11 src string
12 needsHandler bool
13 }{
14 {"/static/static", false},
15 {"/{myparam}", false},
16 {"/{myparam min(1)}", true},
17 {"/{myparam else 500}", true},
18 {"/{myparam else 404}", false},
19 {"/{myparam:string}/static", false},
20 {"/{myparam:int}", true},
21 {"/static/{myparam:int}/static", true},
22 {"/{myparam:path}", false},
23 {"/{myparam:path min(1) else 404}", true},
24 }
25
26 availableMacros := *macro.Defaults
27 for i, tt := range tests {
28 tmpl, err := macro.Parse(tt.src, availableMacros)
29 if err != nil {
30 t.Fatalf("[%d] '%s' failed to be parsed: %v", i, tt.src, err)
31 }
32
33 if got := CanMakeHandler(tmpl); got != tt.needsHandler {
34 if tt.needsHandler {
35 t.Fatalf("[%d] '%s' expected to be able to generate an evaluator handler instead of a nil one", i, tt.src)
36 } else {
37 t.Fatalf("[%d] '%s' should not need an evaluator handler", i, tt.src)
38 }
39 }
40 }
41}

Callers

nothing calls this directly

Calls 3

ParseFunction · 0.92
CanMakeHandlerFunction · 0.85
FatalfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…