MCPcopy Index your code
hub / github.com/labstack/echo / TestToContext_JSONBody

Function TestToContext_JSONBody

echotest/context_test.go:141–157  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

139}
140
141func TestToContext_JSONBody(t *testing.T) {
142 testConf := ContextConfig{
143 JSONBody: LoadBytes(t, "testdata/test.json"),
144 }
145 c := testConf.ToContext(t)
146
147 payload := struct {
148 Field string `json:"field"`
149 }{}
150 if err := c.Bind(&payload); err != nil {
151 t.Fatal(err)
152 }
153
154 assert.Equal(t, "value", payload.Field)
155 assert.Equal(t, http.MethodPost, c.Request().Method)
156 assert.Equal(t, echo.MIMEApplicationJSON, c.Request().Header.Get(echo.HeaderContentType))
157}

Callers

nothing calls this directly

Calls 5

ToContextMethod · 0.95
LoadBytesFunction · 0.85
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…