mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 12:50:55 +00:00
added more test case
This commit is contained in:
parent
faa3341603
commit
453f112094
@ -480,12 +480,40 @@ func TestPointer(t *testing.T) {
|
|||||||
t.Fatal("validation should be passed")
|
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"
|
invalidEmail := "a@a"
|
||||||
u = User{
|
u = User{
|
||||||
ReqEmail: &validEmail,
|
ReqEmail: &validEmail,
|
||||||
Email: &invalidEmail,
|
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{}
|
valid = Validation{}
|
||||||
b, err = valid.Valid(u)
|
b, err = valid.Valid(u)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user