mirror of
https://github.com/astaxie/beego.git
synced 2025-07-10 03:00:19 +00:00
add funcmap
This commit is contained in:
@ -56,3 +56,19 @@ func TestGetValidFuncs(t *testing.T) {
|
||||
t.Error("Range funcs should be got")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCall(t *testing.T) {
|
||||
u := user{Name: "test", Age: 180}
|
||||
tf := reflect.TypeOf(u)
|
||||
var vfs []ValidFunc
|
||||
var err error
|
||||
f, _ := tf.FieldByName("Age")
|
||||
if vfs, err = getValidFuncs(f); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
valid := &Validation{}
|
||||
funcs.Call(vfs[1].Name, valid, u.Age, vfs[1].Params[0], vfs[1].Params[1], vfs[1].Name)
|
||||
if len(valid.Errors) != 1 {
|
||||
t.Error("age out of range should be has an error")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user