MCPcopy
hub / github.com/gin-gonic/gin / TestContextNegotiationWithXML

Function TestContextNegotiationWithXML

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

Source from the content-addressed store, hash-verified

1615}
1616
1617func TestContextNegotiationWithXML(t *testing.T) {
1618 w := httptest.NewRecorder()
1619 c, _ := CreateTestContext(w)
1620 c.Request, _ = http.NewRequest(http.MethodPost, "", nil)
1621
1622 c.Negotiate(http.StatusOK, Negotiate{
1623 Offered: []string{MIMEXML, MIMEJSON, MIMEYAML, MIMEYAML2},
1624 Data: H{"foo": "bar"},
1625 })
1626
1627 assert.Equal(t, http.StatusOK, w.Code)
1628 assert.Equal(t, "<map><foo>bar</foo></map>", w.Body.String())
1629 assert.Equal(t, "application/xml; charset=utf-8", w.Header().Get("Content-Type"))
1630}
1631
1632func TestContextNegotiationWithYAML(t *testing.T) {
1633 w := httptest.NewRecorder()

Callers

nothing calls this directly

Calls 5

CreateTestContextFunction · 0.85
NegotiateMethod · 0.80
StringMethod · 0.65
GetMethod · 0.45
HeaderMethod · 0.45

Tested by

no test coverage detected