(t *testing.T, method, path, badPath, body, badBody string)
| 872 | } |
| 873 | |
| 874 | func testFormBinding(t *testing.T, method, path, badPath, body, badBody string) { |
| 875 | b := Form |
| 876 | assert.Equal(t, "form", b.Name()) |
| 877 | |
| 878 | obj := FooBarStruct{} |
| 879 | req := requestWithBody(method, path, body) |
| 880 | if method == http.MethodPost { |
| 881 | req.Header.Add("Content-Type", MIMEPOSTForm) |
| 882 | } |
| 883 | err := b.Bind(req, &obj) |
| 884 | require.NoError(t, err) |
| 885 | assert.Equal(t, "bar", obj.Foo) |
| 886 | assert.Equal(t, "foo", obj.Bar) |
| 887 | |
| 888 | obj = FooBarStruct{} |
| 889 | req = requestWithBody(method, badPath, badBody) |
| 890 | err = JSON.Bind(req, &obj) |
| 891 | require.Error(t, err) |
| 892 | } |
| 893 | |
| 894 | func testFormBindingDefaultValue(t *testing.T, method, path, badPath, body, badBody string) { |
| 895 | b := Form |
no test coverage detected