(t *testing.T)
| 1600 | } |
| 1601 | |
| 1602 | func TestContextNegotiationWithJSON(t *testing.T) { |
| 1603 | w := httptest.NewRecorder() |
| 1604 | c, _ := CreateTestContext(w) |
| 1605 | c.Request, _ = http.NewRequest(http.MethodPost, "", nil) |
| 1606 | |
| 1607 | c.Negotiate(http.StatusOK, Negotiate{ |
| 1608 | Offered: []string{MIMEJSON, MIMEXML, MIMEYAML, MIMEYAML2}, |
| 1609 | Data: H{"foo": "bar"}, |
| 1610 | }) |
| 1611 | |
| 1612 | assert.Equal(t, http.StatusOK, w.Code) |
| 1613 | assert.JSONEq(t, `{"foo":"bar"}`, w.Body.String()) |
| 1614 | assert.Equal(t, "application/json; charset=utf-8", w.Header().Get("Content-Type")) |
| 1615 | } |
| 1616 | |
| 1617 | func TestContextNegotiationWithXML(t *testing.T) { |
| 1618 | w := httptest.NewRecorder() |
nothing calls this directly
no test coverage detected