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"
|
"io/ioutil"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -584,11 +583,27 @@ func TestFormBindingFail(t *testing.T) {
|
|||||||
assert.Equal(t, b.Name(), "form")
|
assert.Equal(t, b.Name(), "form")
|
||||||
|
|
||||||
obj := FooBarStruct{}
|
obj := FooBarStruct{}
|
||||||
req := &http.Request{
|
req, _ := http.NewRequest("POST", "/", nil)
|
||||||
Method: "POST",
|
err := b.Bind(req, &obj)
|
||||||
Header: http.Header(map[string][]string{}),
|
assert.Error(t, err)
|
||||||
Body: ioutil.NopCloser(strings.NewReader("body")),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
err := b.Bind(req, &obj)
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user