(t *testing.T, method, path, badPath, body, badBody string)
| 892 | } |
| 893 | |
| 894 | func testFormBindingDefaultValue(t *testing.T, method, path, badPath, body, badBody string) { |
| 895 | b := Form |
| 896 | assert.Equal(t, "form", b.Name()) |
| 897 | |
| 898 | obj := FooDefaultBarStruct{} |
| 899 | req := requestWithBody(method, path, body) |
| 900 | if method == http.MethodPost { |
| 901 | req.Header.Add("Content-Type", MIMEPOSTForm) |
| 902 | } |
| 903 | err := b.Bind(req, &obj) |
| 904 | require.NoError(t, err) |
| 905 | assert.Equal(t, "bar", obj.Foo) |
| 906 | assert.Equal(t, "hello", obj.Bar) |
| 907 | |
| 908 | obj = FooDefaultBarStruct{} |
| 909 | req = requestWithBody(method, badPath, badBody) |
| 910 | err = JSON.Bind(req, &obj) |
| 911 | require.Error(t, err) |
| 912 | } |
| 913 | |
| 914 | func TestFormBindingFail(t *testing.T) { |
| 915 | b := Form |
no test coverage detected