(t *testing.T, b Binding, name, path, badPath, body, badBody string)
| 1215 | } |
| 1216 | |
| 1217 | func testBodyBinding(t *testing.T, b Binding, name, path, badPath, body, badBody string) { |
| 1218 | assert.Equal(t, name, b.Name()) |
| 1219 | |
| 1220 | obj := FooStruct{} |
| 1221 | req := requestWithBody(http.MethodPost, path, body) |
| 1222 | err := b.Bind(req, &obj) |
| 1223 | require.NoError(t, err) |
| 1224 | assert.Equal(t, "bar", obj.Foo) |
| 1225 | |
| 1226 | obj = FooStruct{} |
| 1227 | req = requestWithBody(http.MethodPost, badPath, badBody) |
| 1228 | err = JSON.Bind(req, &obj) |
| 1229 | require.Error(t, err) |
| 1230 | } |
| 1231 | |
| 1232 | func testBodyBindingSlice(t *testing.T, b Binding, name, path, badPath, body, badBody string) { |
| 1233 | assert.Equal(t, name, b.Name()) |
no test coverage detected