| 409 | } |
| 410 | |
| 411 | func TestContext_JSON_CommitsCustomResponseCode(t *testing.T) { |
| 412 | e := New() |
| 413 | req := httptest.NewRequest(http.MethodGet, "/", nil) |
| 414 | rec := httptest.NewRecorder() |
| 415 | c := e.NewContext(req, rec) |
| 416 | err := c.JSON(http.StatusCreated, user{ID: 1, Name: "Jon Snow"}) |
| 417 | |
| 418 | if assert.NoError(t, err) { |
| 419 | assert.Equal(t, http.StatusCreated, rec.Code) |
| 420 | assert.Equal(t, MIMEApplicationJSON, rec.Header().Get(HeaderContentType)) |
| 421 | assert.Equal(t, userJSON+"\n", rec.Body.String()) |
| 422 | } |
| 423 | } |
| 424 | |
| 425 | func TestContextAttachment(t *testing.T) { |
| 426 | var testCases = []struct { |