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
07ca1820a8
commit
fe41f6287f
@ -11,7 +11,6 @@ import (
|
||||
"io/ioutil"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -584,11 +583,27 @@ func TestFormBindingFail(t *testing.T) {
|
||||
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")),
|
||||
}
|
||||
req, _ := http.NewRequest("POST", "/", nil)
|
||||
err := b.Bind(req, &obj)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestFormPostBindingFail(t *testing.T) {
|
||||
b := FormPost
|
||||
assert.Equal(t, b.Name(), "form-urlencoded")
|
||||
|
||||
obj := FooBarStruct{}
|
||||
req, _ := http.NewRequest("POST", "/", nil)
|
||||
err := b.Bind(req, &obj)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestFormMultipartBindingFail(t *testing.T) {
|
||||
b := FormMultipart
|
||||
assert.Equal(t, b.Name(), "multipart/form-data")
|
||||
|
||||
obj := FooBarStruct{}
|
||||
req, _ := http.NewRequest("POST", "/", nil)
|
||||
err := b.Bind(req, &obj)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user