(t *testing.T)
| 2137 | } |
| 2138 | |
| 2139 | func TestContextAutoBindJSON(t *testing.T) { |
| 2140 | c, _ := CreateTestContext(httptest.NewRecorder()) |
| 2141 | c.Request, _ = http.NewRequest(http.MethodPost, "/", strings.NewReader(`{"foo":"bar", "bar":"foo"}`)) |
| 2142 | c.Request.Header.Add("Content-Type", MIMEJSON) |
| 2143 | |
| 2144 | var obj struct { |
| 2145 | Foo string `json:"foo"` |
| 2146 | Bar string `json:"bar"` |
| 2147 | } |
| 2148 | require.NoError(t, c.Bind(&obj)) |
| 2149 | assert.Equal(t, "foo", obj.Bar) |
| 2150 | assert.Equal(t, "bar", obj.Foo) |
| 2151 | assert.Empty(t, c.Errors) |
| 2152 | } |
| 2153 | |
| 2154 | func TestContextBindWithJSON(t *testing.T) { |
| 2155 | w := httptest.NewRecorder() |
nothing calls this directly
no test coverage detected