MCPcopy
hub / github.com/labstack/echo / TestContextXML

Function TestContextXML

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

Source from the content-addressed store, hash-verified

344}
345
346func TestContextXML(t *testing.T) {
347 e := New()
348 rec := httptest.NewRecorder()
349 req := httptest.NewRequest(http.MethodGet, "/", nil)
350 c := e.NewContext(req, rec)
351
352 err := c.XML(http.StatusOK, user{ID: 1, Name: "Jon Snow"})
353 if assert.NoError(t, err) {
354 assert.Equal(t, http.StatusOK, rec.Code)
355 assert.Equal(t, MIMEApplicationXMLCharsetUTF8, rec.Header().Get(HeaderContentType))
356 assert.Equal(t, xml.Header+userXML, rec.Body.String())
357 }
358}
359
360func TestContextXMLPretty(t *testing.T) {
361 e := New()

Callers

nothing calls this directly

Calls 6

XMLMethod · 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…