MCPcopy
hub / github.com/gofiber/fiber / Test_Ctx_RenderWithOverwrittenViewBind

Function Test_Ctx_RenderWithOverwrittenViewBind

ctx_test.go:7822–7842  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7820}
7821
7822func Test_Ctx_RenderWithOverwrittenViewBind(t *testing.T) {
7823 t.Parallel()
7824 app := New()
7825 c := app.AcquireCtx(&fasthttp.RequestCtx{})
7826
7827 err := c.ViewBind(Map{
7828 "Title": "Hello, World!",
7829 })
7830 require.NoError(t, err)
7831
7832 err = c.Render("./.github/testdata/index.tmpl", Map{
7833 "Title": "Hello from Fiber!",
7834 })
7835 require.NoError(t, err)
7836
7837 buf := bytebufferpool.Get()
7838 buf.WriteString("overwrite")
7839 defer bytebufferpool.Put(buf)
7840
7841 require.Equal(t, "<h1>Hello from Fiber!</h1>", string(c.Response().Body()))
7842}
7843
7844func Test_Ctx_RenderWithViewBindLocals(t *testing.T) {
7845 t.Parallel()

Callers

nothing calls this directly

Calls 9

AcquireCtxMethod · 0.80
NewFunction · 0.70
ViewBindMethod · 0.65
RenderMethod · 0.65
GetMethod · 0.65
WriteStringMethod · 0.65
PutMethod · 0.65
BodyMethod · 0.65
ResponseMethod · 0.65

Tested by

no test coverage detected