mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 01:00:54 +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")
|
||||
}
|
||||
|
||||
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user