| 1704 | } |
| 1705 | |
| 1706 | func 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 | |
| 1723 | func TestContextNegotiationNotSupport(t *testing.T) { |
| 1724 | w := httptest.NewRecorder() |