MCPcopy Index your code
hub / github.com/labstack/echo / TestContextXMLWithEmptyIntent

Function TestContextXMLWithEmptyIntent

context_test.go:390–409  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

388}
389
390func 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
411func TestContext_JSON_CommitsCustomResponseCode(t *testing.T) {
412 e := New()

Callers

nothing calls this directly

Calls 6

XMLPrettyMethod · 0.95
NewFunction · 0.85
NewContextMethod · 0.80
GetMethod · 0.45
HeaderMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…