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

Function TestContextNegotiationWithBSON

context_test.go:1706–1721  ·  context_test.go::TestContextNegotiationWithBSON
(t *testing.T)

Source from the content-addressed store, hash-verified

1704}
1705
1706func TestContextNegotiationWithBSON(t *testing.T) {
1707 w := httptest.NewRecorder()
1708 c, _ := CreateTestContext(w)
1709 c.Request, _ = http.NewRequest(http.MethodPost, "", nil)
1710
1711 c.Negotiate(http.StatusOK, Negotiate{
1712 Offered: []string{MIMEBSON, MIMEXML, MIMEJSON, MIMEYAML, MIMEYAML2},
1713 Data: H{"foo": "bar"},
1714 })
1715
1716 bData, _ := bson.Marshal(H{"foo": "bar"})
1717
1718 assert.Equal(t, http.StatusOK, w.Code)
1719 assert.Equal(t, string(bData), w.Body.String())
1720 assert.Equal(t, "application/bson", w.Header().Get("Content-Type"))
1721}
1722
1723func TestContextNegotiationNotSupport(t *testing.T) {
1724 w := httptest.NewRecorder()

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected