(t *testing.T)
| 2152 | } |
| 2153 | |
| 2154 | func TestContextBindWithJSON(t *testing.T) { |
| 2155 | w := httptest.NewRecorder() |
| 2156 | c, _ := CreateTestContext(w) |
| 2157 | |
| 2158 | c.Request, _ = http.NewRequest(http.MethodPost, "/", strings.NewReader(`{"foo":"bar", "bar":"foo"}`)) |
| 2159 | c.Request.Header.Add("Content-Type", MIMEXML) // set fake content-type |
| 2160 | |
| 2161 | var obj struct { |
| 2162 | Foo string `json:"foo"` |
| 2163 | Bar string `json:"bar"` |
| 2164 | } |
| 2165 | require.NoError(t, c.BindJSON(&obj)) |
| 2166 | assert.Equal(t, "foo", obj.Bar) |
| 2167 | assert.Equal(t, "bar", obj.Foo) |
| 2168 | assert.Equal(t, 0, w.Body.Len()) |
| 2169 | } |
| 2170 | |
| 2171 | func TestContextBindWithXML(t *testing.T) { |
| 2172 | w := httptest.NewRecorder() |
nothing calls this directly
no test coverage detected