1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-22 18:10:48 +00:00

added more test case

This commit is contained in:
Andrea Spacca 2018-02-01 18:30:31 +01:00
parent faa3341603
commit 453f112094

View File

@ -480,12 +480,40 @@ func TestPointer(t *testing.T) {
t.Fatal("validation should be passed")
}
u = User{
ReqEmail: &validEmail,
Email: nil,
}
valid = Validation{}
b, err = valid.Valid(u)
if err != nil {
t.Fatal(err)
}
if !b {
t.Fatal("validation should be passed")
}
invalidEmail := "a@a"
u = User{
ReqEmail: &validEmail,
Email: &invalidEmail,
}
valid = Validation{RequiredFirst: true}
b, err = valid.Valid(u)
if err != nil {
t.Fatal(err)
}
if b {
t.Fatal("validation should not be passed")
}
u = User{
ReqEmail: &validEmail,
Email: &invalidEmail,
}
valid = Validation{}
b, err = valid.Valid(u)
if err != nil {