mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 07:50:54 +00:00
add testing for ParseForm when form post has a slice in body
This commit is contained in:
parent
12fdc04f1b
commit
920207f72c
@ -111,7 +111,7 @@ func TestHtmlunquote(t *testing.T) {
|
|||||||
|
|
||||||
func TestParseForm(t *testing.T) {
|
func TestParseForm(t *testing.T) {
|
||||||
type ExtendInfo struct {
|
type ExtendInfo struct {
|
||||||
Hobby string `form:"hobby"`
|
Hobby []string `form:"hobby"`
|
||||||
Memo string
|
Memo string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ func TestParseForm(t *testing.T) {
|
|||||||
"date": []string{"2014-11-12"},
|
"date": []string{"2014-11-12"},
|
||||||
"organization": []string{"beego"},
|
"organization": []string{"beego"},
|
||||||
"title": []string{"CXO"},
|
"title": []string{"CXO"},
|
||||||
"hobby": []string{"Basketball"},
|
"hobby": []string{"Basketball", "Football"},
|
||||||
"memo": []string{"nothing"},
|
"memo": []string{"nothing"},
|
||||||
}
|
}
|
||||||
if err := ParseForm(form, u); err == nil {
|
if err := ParseForm(form, u); err == nil {
|
||||||
@ -186,8 +186,11 @@ func TestParseForm(t *testing.T) {
|
|||||||
if u.Title != "CXO" {
|
if u.Title != "CXO" {
|
||||||
t.Errorf("Title should equal `CXO`, but got `%v`", u.Title)
|
t.Errorf("Title should equal `CXO`, but got `%v`", u.Title)
|
||||||
}
|
}
|
||||||
if u.Hobby != "Basketball" {
|
if u.Hobby[0] != "Basketball" {
|
||||||
t.Errorf("Hobby should equal `Basketball`, but got `%v`", u.Hobby)
|
t.Errorf("Hobby should equal `Basketball`, but got `%v`", u.Hobby[0])
|
||||||
|
}
|
||||||
|
if u.Hobby[1] != "Football" {
|
||||||
|
t.Errorf("Hobby should equal `Football`, but got `%v`", u.Hobby[1])
|
||||||
}
|
}
|
||||||
if len(u.Memo) != 0 {
|
if len(u.Memo) != 0 {
|
||||||
t.Errorf("Memo's length should equal 0 but got %v", len(u.Memo))
|
t.Errorf("Memo's length should equal 0 but got %v", len(u.Memo))
|
||||||
|
Loading…
Reference in New Issue
Block a user