Tests that the response is serialized as JSON and Content-Type is set to application/json
(t *testing.T)
| 1139 | // Tests that the response is serialized as JSON |
| 1140 | // and Content-Type is set to application/json |
| 1141 | func TestContextRenderIndentedJSON(t *testing.T) { |
| 1142 | w := httptest.NewRecorder() |
| 1143 | c, _ := CreateTestContext(w) |
| 1144 | |
| 1145 | c.IndentedJSON(http.StatusCreated, H{"foo": "bar", "bar": "foo", "nested": H{"foo": "bar"}}) |
| 1146 | |
| 1147 | assert.Equal(t, http.StatusCreated, w.Code) |
| 1148 | assert.JSONEq(t, "{\n \"bar\": \"foo\",\n \"foo\": \"bar\",\n \"nested\": {\n \"foo\": \"bar\"\n }\n}", w.Body.String()) |
| 1149 | assert.Equal(t, "application/json; charset=utf-8", w.Header().Get("Content-Type")) |
| 1150 | } |
| 1151 | |
| 1152 | // Tests that no Custom JSON is rendered if code is 204 |
| 1153 | func TestContextRenderNoContentIndentedJSON(t *testing.T) { |
nothing calls this directly
no test coverage detected