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

Unified Diff: service/datastore/datastore_test.go

Issue 1358743002: Make Get operations only serialize the bare minimum. (Closed) Base URL: https://github.com/luci/gae.git@fix_time
Patch Set: PropertyMap should always copy on save-out functions to avoid external mutation Created 5 years, 3 months 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/datastore.go ('k') | service/datastore/multiarg.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/datastore/datastore_test.go
diff --git a/service/datastore/datastore_test.go b/service/datastore/datastore_test.go
index 86246c84607a067b0362f8492a1d494f1bcdc50e..c0343ff1f2929e7b615ed404156147dddde1415d 100644
--- a/service/datastore/datastore_test.go
+++ b/service/datastore/datastore_test.go
@@ -201,6 +201,17 @@ func (f *FakePLS) GetMeta(key string) (interface{}, error) {
return nil, ErrMetaFieldUnset
}
+func (f *FakePLS) GetAllMeta() PropertyMap {
+ ret := PropertyMap{}
+ if id, err := f.GetMeta("id"); err != nil {
+ So(ret.SetMeta("id", id), ShouldBeNil)
+ }
+ if kind, err := f.GetMeta("kind"); err != nil {
+ So(ret.SetMeta("kind", kind), ShouldBeNil)
+ }
+ return ret
+}
+
func (f *FakePLS) SetMeta(key string, val interface{}) error {
if f.failSetMeta {
return errors.New("FakePL.SetMeta")
@@ -577,8 +588,8 @@ func TestGet(t *testing.T) {
})
Convey("failure to save metadata is an issue too", func() {
- cs := &FakePLS{failSave: true}
- So(ds.Get(cs).Error(), ShouldContainSubstring, "FakePLS.Save")
+ cs := &FakePLS{failGetMeta: true}
+ So(ds.Get(cs).Error(), ShouldContainSubstring, "unable to extract $kind")
})
})
@@ -597,6 +608,11 @@ func TestGet(t *testing.T) {
So(pm["Value"][0].Value(), ShouldEqual, 1)
}), ShouldBeNil)
})
+
+ Convey("but general failure to save is fine on a Get", func() {
+ cs := &FakePLS{failSave: true, IntID: 7}
+ So(ds.Get(cs), ShouldBeNil)
+ })
})
})
« no previous file with comments | « service/datastore/datastore.go ('k') | service/datastore/multiarg.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698