MCPcopy
hub / github.com/gin-gonic/gin / setupHTMLFiles

Function setupHTMLFiles

gin_test.go:32–63  ·  view source on GitHub ↗
(t *testing.T, mode string, tls bool, loadMethod func(*Engine))

Source from the content-addressed store, hash-verified

30}
31
32func 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
65func TestLoadHTMLGlobDebugMode(t *testing.T) {
66 ts := setupHTMLFiles(

Callers 15

TestLoadHTMLGlobTestModeFunction · 0.85
TestLoadHTMLGlobUsingTLSFunction · 0.85
TestLoadHTMLFilesFuncMapFunction · 0.85
TestLoadHTMLFSTestModeFunction · 0.85
TestLoadHTMLFSDebugModeFunction · 0.85

Calls 7

DelimsMethod · 0.95
SetFuncMapMethod · 0.95
SetModeFunction · 0.85
captureOutputFunction · 0.85
NewFunction · 0.85
HTMLMethod · 0.80
GETMethod · 0.65

Tested by

no test coverage detected