Index: service/datastore/pls_test.go |
diff --git a/service/datastore/pls_test.go b/service/datastore/pls_test.go |
index 322107e8521bf212169cbd88a78a6aa8fec797de..92ebffcf0b4521a9b5bc4f3912a24e840aa59157 100644 |
--- a/service/datastore/pls_test.go |
+++ b/service/datastore/pls_test.go |
@@ -1886,6 +1886,29 @@ func TestMeta(t *testing.T) { |
So(v, ShouldEqual, int64(10)) |
}) |
+ Convey("Derived metadata fields", func() { |
+ type DerivedString string |
+ type DerivedInt int16 |
+ type DerivedStruct struct { |
+ ID DerivedString `gae:"$id"` |
+ Foo DerivedInt `gae:"$foo"` |
+ } |
+ o := &DerivedStruct{"hello", 10} |
+ mgs := getMGS(o) |
+ v, err := mgs.GetMeta("id") |
+ So(err, ShouldBeNil) |
+ So(v, ShouldEqual, "hello") |
+ |
+ v, err = mgs.GetMeta("foo") |
+ So(err, ShouldBeNil) |
+ So(v, ShouldEqual, int64(10)) |
+ |
+ So(mgs.SetMeta("id", "nerds"), ShouldBeNil) |
+ So(mgs.SetMeta("foo", 20), ShouldBeNil) |
+ So(o.ID, ShouldEqual, DerivedString("nerds")) |
+ So(o.Foo, ShouldEqual, DerivedInt(20)) |
+ }) |
+ |
Convey("Bad default meta type", func() { |
type BadDefault struct { |
Val time.Time `gae:"$meta,tomorrow"` |