mirror of
https://github.com/astaxie/beego.git
synced 2024-11-01 03:20:55 +00:00
add test case fot date & stringbool
This commit is contained in:
parent
7743eecfd4
commit
b9fdd67519
@ -108,6 +108,8 @@ func TestParseForm(t *testing.T) {
|
|||||||
Age int `form:"age,text"`
|
Age int `form:"age,text"`
|
||||||
Email string
|
Email string
|
||||||
Intro string `form:",textarea"`
|
Intro string `form:",textarea"`
|
||||||
|
StrBool bool `form:"strbool"`
|
||||||
|
Date time.Time `form:"date,2006-01-02"`
|
||||||
}
|
}
|
||||||
|
|
||||||
u := user{}
|
u := user{}
|
||||||
@ -119,6 +121,8 @@ func TestParseForm(t *testing.T) {
|
|||||||
"age": []string{"40"},
|
"age": []string{"40"},
|
||||||
"Email": []string{"test@gmail.com"},
|
"Email": []string{"test@gmail.com"},
|
||||||
"Intro": []string{"I am an engineer!"},
|
"Intro": []string{"I am an engineer!"},
|
||||||
|
"strbool": []string{"yes"},
|
||||||
|
"date": []string{"2014-11-12"},
|
||||||
}
|
}
|
||||||
if err := ParseForm(form, u); err == nil {
|
if err := ParseForm(form, u); err == nil {
|
||||||
t.Fatal("nothing will be changed")
|
t.Fatal("nothing will be changed")
|
||||||
@ -144,6 +148,13 @@ func TestParseForm(t *testing.T) {
|
|||||||
if u.Intro != "I am an engineer!" {
|
if u.Intro != "I am an engineer!" {
|
||||||
t.Errorf("Intro should equal `I am an engineer!` but got `%v`", u.Intro)
|
t.Errorf("Intro should equal `I am an engineer!` but got `%v`", u.Intro)
|
||||||
}
|
}
|
||||||
|
if u.StrBool != true {
|
||||||
|
t.Errorf("strboll should equal `true`, but got `%v`", u.StrBool)
|
||||||
|
}
|
||||||
|
y, m, d := u.Date.Date()
|
||||||
|
if y != 2014 || m.String() != "November" || d != 12 {
|
||||||
|
t.Errorf("Date should equal `2014-11-12`, but got `%v`", u.Date.String())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRenderForm(t *testing.T) {
|
func TestRenderForm(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user