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

Function TestCreateTestContextWithRouteParams

context_test.go:3328–3340  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3326}
3327
3328func TestCreateTestContextWithRouteParams(t *testing.T) {
3329 w := httptest.NewRecorder()
3330 engine := New()
3331 engine.GET("/:action/:name", func(ctx *Context) {
3332 ctx.String(http.StatusOK, "%s %s", ctx.Param("action"), ctx.Param("name"))
3333 })
3334 c := CreateTestContextOnly(w, engine)
3335 c.Request, _ = http.NewRequest(http.MethodGet, "/hello/gin", nil)
3336 engine.HandleContext(c)
3337
3338 assert.Equal(t, http.StatusOK, w.Code)
3339 assert.Equal(t, "hello gin", w.Body.String())
3340}
3341
3342type interceptedWriter struct {
3343 ResponseWriter

Callers

nothing calls this directly

Calls 6

NewFunction · 0.85
CreateTestContextOnlyFunction · 0.85
ParamMethod · 0.80
HandleContextMethod · 0.80
GETMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected