mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-24 02:32:17 +08:00
add test case
This commit is contained in:
parent
f9b4e94277
commit
1c933e01b2
@ -11,6 +11,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -578,6 +579,20 @@ func testFormBinding(t *testing.T, method, path, badPath, body, badBody string)
|
|||||||
assert.Error(t, err)
|
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) {
|
func testFormBindingForTime(t *testing.T, method, path, badPath, body, badBody string) {
|
||||||
b := Form
|
b := Form
|
||||||
assert.Equal(t, b.Name(), "form")
|
assert.Equal(t, b.Name(), "form")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user