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

Function TestContextNegotiationWithYAML

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

Source from the content-addressed store, hash-verified

1630}
1631
1632func TestContextNegotiationWithYAML(t *testing.T) {
1633 w := httptest.NewRecorder()
1634 c, _ := CreateTestContext(w)
1635 c.Request, _ = http.NewRequest(http.MethodPost, "", nil)
1636
1637 c.Negotiate(http.StatusOK, Negotiate{
1638 Offered: []string{MIMEYAML, MIMEXML, MIMEJSON, MIMETOML, MIMEYAML2},
1639 Data: H{"foo": "bar"},
1640 })
1641
1642 assert.Equal(t, http.StatusOK, w.Code)
1643 assert.Equal(t, "foo: bar\n", w.Body.String())
1644 assert.Equal(t, "application/yaml; charset=utf-8", w.Header().Get("Content-Type"))
1645}
1646
1647func TestContextNegotiationWithTOML(t *testing.T) {
1648 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