(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…