(t *testing.T)
| 2286 | } |
| 2287 | |
| 2288 | func TestContextBadAutoBind(t *testing.T) { |
| 2289 | w := httptest.NewRecorder() |
| 2290 | c, _ := CreateTestContext(w) |
| 2291 | |
| 2292 | c.Request, _ = http.NewRequest(http.MethodPost, "http://example.com", strings.NewReader("\"foo\":\"bar\", \"bar\":\"foo\"}")) |
| 2293 | c.Request.Header.Add("Content-Type", MIMEJSON) |
| 2294 | var obj struct { |
| 2295 | Foo string `json:"foo"` |
| 2296 | Bar string `json:"bar"` |
| 2297 | } |
| 2298 | |
| 2299 | assert.False(t, c.IsAborted()) |
| 2300 | require.Error(t, c.Bind(&obj)) |
| 2301 | c.Writer.WriteHeaderNow() |
| 2302 | |
| 2303 | assert.Empty(t, obj.Bar) |
| 2304 | assert.Empty(t, obj.Foo) |
| 2305 | assert.Equal(t, http.StatusBadRequest, w.Code) |
| 2306 | assert.True(t, c.IsAborted()) |
| 2307 | } |
| 2308 | |
| 2309 | func TestContextAutoShouldBindJSON(t *testing.T) { |
| 2310 | c, _ := CreateTestContext(httptest.NewRecorder()) |
nothing calls this directly
no test coverage detected