Tests that no HTML is rendered if code is 204
(t *testing.T)
| 1283 | |
| 1284 | // Tests that no HTML is rendered if code is 204 |
| 1285 | func TestContextRenderNoContentHTML(t *testing.T) { |
| 1286 | w := httptest.NewRecorder() |
| 1287 | c, router := CreateTestContext(w) |
| 1288 | templ := template.Must(template.New("t").Parse(`Hello {{.name}}`)) |
| 1289 | router.SetHTMLTemplate(templ) |
| 1290 | |
| 1291 | c.HTML(http.StatusNoContent, "t", H{"name": "alexandernyquist"}) |
| 1292 | |
| 1293 | assert.Equal(t, http.StatusNoContent, w.Code) |
| 1294 | assert.Empty(t, w.Body.String()) |
| 1295 | assert.Equal(t, "text/html; charset=utf-8", w.Header().Get("Content-Type")) |
| 1296 | } |
| 1297 | |
| 1298 | // TestContextRenderXML tests that the response is serialized as XML |
| 1299 | // and Content-Type is set to application/xml |
nothing calls this directly
no test coverage detected