Tests that the response is serialized as JSON we change the content-type before
(t *testing.T)
| 1112 | // Tests that the response is serialized as JSON |
| 1113 | // we change the content-type before |
| 1114 | func TestContextRenderAPIJSON(t *testing.T) { |
| 1115 | w := httptest.NewRecorder() |
| 1116 | c, _ := CreateTestContext(w) |
| 1117 | |
| 1118 | c.Header("Content-Type", "application/vnd.api+json") |
| 1119 | c.JSON(http.StatusCreated, H{"foo": "bar"}) |
| 1120 | |
| 1121 | assert.Equal(t, http.StatusCreated, w.Code) |
| 1122 | assert.JSONEq(t, `{"foo":"bar"}`, w.Body.String()) |
| 1123 | assert.Equal(t, "application/vnd.api+json", w.Header().Get("Content-Type")) |
| 1124 | } |
| 1125 | |
| 1126 | // Tests that no Custom JSON is rendered if code is 204 |
| 1127 | func TestContextRenderNoContentAPIJSON(t *testing.T) { |
nothing calls this directly
no test coverage detected