Tests that the response executes the templates and responds with Content-Type set to text/html
(t *testing.T)
| 1244 | // Tests that the response executes the templates |
| 1245 | // and responds with Content-Type set to text/html |
| 1246 | func TestContextRenderHTML(t *testing.T) { |
| 1247 | w := httptest.NewRecorder() |
| 1248 | c, router := CreateTestContext(w) |
| 1249 | |
| 1250 | templ := template.Must(template.New("t").Parse(`Hello {{.name}}`)) |
| 1251 | router.SetHTMLTemplate(templ) |
| 1252 | |
| 1253 | c.HTML(http.StatusCreated, "t", H{"name": "alexandernyquist"}) |
| 1254 | |
| 1255 | assert.Equal(t, http.StatusCreated, w.Code) |
| 1256 | assert.Equal(t, "Hello alexandernyquist", w.Body.String()) |
| 1257 | assert.Equal(t, "text/html; charset=utf-8", w.Header().Get("Content-Type")) |
| 1258 | } |
| 1259 | |
| 1260 | func TestContextRenderHTML2(t *testing.T) { |
| 1261 | w := httptest.NewRecorder() |
nothing calls this directly
no test coverage detected