Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Unified Diff: service/datastore/pls_test.go

Issue 1494803005: GAE Datastore - Fix derived types not being reflected properly (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: Remove debug prints Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « service/datastore/pls_impl.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"`
« no previous file with comments | « service/datastore/pls_impl.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698