(t *testing.T, mode string, tls bool, loadMethod func(*Engine))
| 30 | } |
| 31 | |
| 32 | func setupHTMLFiles(t *testing.T, mode string, tls bool, loadMethod func(*Engine)) *httptest.Server { |
| 33 | SetMode(mode) |
| 34 | defer SetMode(TestMode) |
| 35 | |
| 36 | var router *Engine |
| 37 | captureOutput(t, func() { |
| 38 | router = New() |
| 39 | router.Delims("{[{", "}]}") |
| 40 | router.SetFuncMap(template.FuncMap{ |
| 41 | "formatAsDate": formatAsDate, |
| 42 | }) |
| 43 | loadMethod(router) |
| 44 | router.GET("/test", func(c *Context) { |
| 45 | c.HTML(http.StatusOK, "hello.tmpl", map[string]string{"name": "world"}) |
| 46 | }) |
| 47 | router.GET("/raw", func(c *Context) { |
| 48 | c.HTML(http.StatusOK, "raw.tmpl", map[string]any{ |
| 49 | "now": time.Date(2017, 07, 01, 0, 0, 0, 0, time.UTC), //nolint:gofumpt |
| 50 | }) |
| 51 | }) |
| 52 | }) |
| 53 | |
| 54 | var ts *httptest.Server |
| 55 | |
| 56 | if tls { |
| 57 | ts = httptest.NewTLSServer(router) |
| 58 | } else { |
| 59 | ts = httptest.NewServer(router) |
| 60 | } |
| 61 | |
| 62 | return ts |
| 63 | } |
| 64 | |
| 65 | func TestLoadHTMLGlobDebugMode(t *testing.T) { |
| 66 | ts := setupHTMLFiles( |
no test coverage detected