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

Function Test_Ctx_Render_MountGroup

mount_test.go:608–636  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

606}
607
608func Test_Ctx_Render_MountGroup(t *testing.T) {
609 t.Parallel()
610
611 engine := &testTemplateEngine{}
612 err := engine.Load()
613 require.NoError(t, err)
614
615 micro := New(Config{
616 Views: engine,
617 })
618
619 micro.Get("/doe", func(c Ctx) error {
620 return c.Render("hello_world.tmpl", Map{
621 "Name": "doe",
622 })
623 })
624
625 app := New()
626 v1 := app.Group("/v1")
627 v1.Use("/john", micro)
628
629 resp, err := app.Test(httptest.NewRequest(MethodGet, "/v1/john/doe", http.NoBody))
630 require.NoError(t, err, "app.Test(req)")
631 require.Equal(t, 200, resp.StatusCode, "Status code")
632
633 body, err := io.ReadAll(resp.Body)
634 require.NoError(t, err)
635 require.Equal(t, "<h1>Hello doe!</h1>", string(body))
636}

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected