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

Function Test_Ctx_Render_Mount

mount_test.go:507–534  ·  view source on GitHub ↗

go test -run Test_Ctx_Render_Mount

(t *testing.T)

Source from the content-addressed store, hash-verified

505
506// go test -run Test_Ctx_Render_Mount
507func Test_Ctx_Render_Mount(t *testing.T) {
508 t.Parallel()
509
510 engine := &testTemplateEngine{}
511 err := engine.Load()
512 require.NoError(t, err)
513
514 sub := New(Config{
515 Views: engine,
516 })
517
518 sub.Get("/:name", func(c Ctx) error {
519 return c.Render("hello_world.tmpl", Map{
520 "Name": c.Params("name"),
521 })
522 })
523
524 app := New()
525 app.Use("/hello", sub)
526
527 resp, err := app.Test(httptest.NewRequest(MethodGet, "/hello/a", http.NoBody))
528 require.Equal(t, StatusOK, resp.StatusCode, "Status code")
529 require.NoError(t, err, "app.Test(req)")
530
531 body, err := io.ReadAll(resp.Body)
532 require.NoError(t, err)
533 require.Equal(t, "<h1>Hello a!</h1>", string(body))
534}
535
536// go test -run Test_Ctx_Render_Mount_ParentOrSubHasViews
537func Test_Ctx_Render_Mount_ParentOrSubHasViews(t *testing.T) {

Callers

nothing calls this directly

Calls 7

LoadMethod · 0.95
TestMethod · 0.80
NewFunction · 0.70
GetMethod · 0.65
RenderMethod · 0.65
ParamsMethod · 0.65
UseMethod · 0.65

Tested by

no test coverage detected