Refactor Meta test structure
@@ -9,8 +9,7 @@ import (
"github.com/qor/qor/test/utils"
)
-func TestValuerAndSetter(t *testing.T) {
- checker := func(record interface{}, meta *resource.Meta, value interface{}) {
+func checkMeta(record interface{}, meta *resource.Meta, value interface{}, t *testing.T) {
var (
context = &qor.Context{DB: utils.TestDB()}
metaValue = &resource.MetaValue{Name: meta.Name, Value: value}
@@ -29,6 +28,7 @@ func TestValuerAndSetter(t *testing.T) {
}
}
+func TestStringMetaValuerAndSetter(t *testing.T) {
user := &struct {
Name string
}{}
@@ -40,5 +40,20 @@ func TestValuerAndSetter(t *testing.T) {
BaseResource: res,
}
- checker(&user, nameMeta, "hello world")
+ checkMeta(&user, nameMeta, "hello world", t)
+}
+
+func TestIntMetaValuerAndSetter(t *testing.T) {
+ user := &struct {
+ Age int
+ }{}
+
+ res := resource.New(&user)
+
+ meta := &resource.Meta{
+ Name: "Age",
+ BaseResource: res,
+ }
+
+ checkMeta(&user, meta, 18, t)
}
