(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func 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 | } |