add test case

This commit is contained in:
thinkerou 2017-11-26 21:45:59 +08:00
parent f9b4e94277
commit 1c933e01b2

View File

@ -11,6 +11,7 @@ import (
"io/ioutil"
"mime/multipart"
"net/http"
"strings"
"testing"
"time"
@ -578,6 +579,20 @@ func testFormBinding(t *testing.T, method, path, badPath, body, badBody string)
assert.Error(t, err)
}
func TestFormBindingFail(t *testing.T) {
b := Form
assert.Equal(t, b.Name(), "form")
obj := FooBarStruct{}
req := &http.Request{
Method: "POST",
Header: http.Header(map[string][]string{}),
Body: ioutil.NopCloser(strings.NewReader("body")),
}
err := b.Bind(req, &obj)
assert.Error(t, err)
}
func testFormBindingForTime(t *testing.T, method, path, badPath, body, badBody string) {
b := Form
assert.Equal(t, b.Name(), "form")