(t *testing.T)
| 139 | } |
| 140 | |
| 141 | func 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 | } |