MCPcopy
hub / github.com/labstack/echo / TestToContext_JSONBody

Function TestToContext_JSONBody

echotest/context_external_test.go:12–27  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestToContext_JSONBody(t *testing.T) {
13 c := echotest.ContextConfig{
14 JSONBody: echotest.LoadBytes(t, "testdata/test.json"),
15 }.ToContext(t)
16
17 payload := struct {
18 Field string `json:"field"`
19 }{}
20 if err := c.Bind(&payload); err != nil {
21 t.Fatal(err)
22 }
23
24 assert.Equal(t, "value", payload.Field)
25 assert.Equal(t, http.MethodPost, c.Request().Method)
26 assert.Equal(t, echo.MIMEApplicationJSON, c.Request().Header.Get(echo.HeaderContentType))
27}

Callers

nothing calls this directly

Calls 5

LoadBytesFunction · 0.92
ToContextMethod · 0.80
RequestMethod · 0.80
BindMethod · 0.65
GetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…