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

Function Test_Ctx_RenderWithViewBind

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

Source from the content-addressed store, hash-verified

7799}
7800
7801func Test_Ctx_RenderWithViewBind(t *testing.T) {
7802 t.Parallel()
7803
7804 app := New()
7805 c := app.AcquireCtx(&fasthttp.RequestCtx{})
7806
7807 err := c.ViewBind(Map{
7808 "Title": "Hello, World!",
7809 })
7810 require.NoError(t, err)
7811
7812 err = c.Render("./.github/testdata/index.tmpl", Map{})
7813 require.NoError(t, err)
7814 buf := bytebufferpool.Get()
7815 buf.WriteString("overwrite")
7816 defer bytebufferpool.Put(buf)
7817
7818 require.NoError(t, err)
7819 require.Equal(t, "<h1>Hello, World!</h1>", string(c.Response().Body()))
7820}
7821
7822func Test_Ctx_RenderWithOverwrittenViewBind(t *testing.T) {
7823 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