| 388 | } |
| 389 | |
| 390 | func TestContextXMLWithEmptyIntent(t *testing.T) { |
| 391 | e := New() |
| 392 | rec := httptest.NewRecorder() |
| 393 | req := httptest.NewRequest(http.MethodGet, "/", nil) |
| 394 | c := e.NewContext(req, rec) |
| 395 | |
| 396 | u := user{ID: 1, Name: "Jon Snow"} |
| 397 | emptyIndent := "" |
| 398 | buf := new(bytes.Buffer) |
| 399 | |
| 400 | enc := xml.NewEncoder(buf) |
| 401 | enc.Indent(emptyIndent, emptyIndent) |
| 402 | _ = enc.Encode(u) |
| 403 | err := c.XMLPretty(http.StatusOK, user{ID: 1, Name: "Jon Snow"}, emptyIndent) |
| 404 | if assert.NoError(t, err) { |
| 405 | assert.Equal(t, http.StatusOK, rec.Code) |
| 406 | assert.Equal(t, MIMEApplicationXMLCharsetUTF8, rec.Header().Get(HeaderContentType)) |
| 407 | assert.Equal(t, xml.Header+buf.String(), rec.Body.String()) |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | func TestContext_JSON_CommitsCustomResponseCode(t *testing.T) { |
| 412 | e := New() |