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

Unified Diff: service/datastore/meta/eg_test.go

Issue 1917513002: Add meta package to datastore. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Updated w/ comments. Created 4 years, 8 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/meta/eg.go ('k') | service/datastore/meta/namespaces.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: service/datastore/meta/eg_test.go
diff --git a/service/datastore/meta/eg_test.go b/service/datastore/meta/eg_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..878a8828769fbd8b7f416c75d15df87f7d54c158
--- /dev/null
+++ b/service/datastore/meta/eg_test.go
@@ -0,0 +1,53 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package meta
+
+import (
+ "errors"
+ "testing"
+
+ "github.com/luci/gae/filter/featureBreaker"
+ "github.com/luci/gae/impl/memory"
+ "github.com/luci/gae/service/datastore"
+ . "github.com/smartystreets/goconvey/convey"
+ "golang.org/x/net/context"
+)
+
+func TestGetEntityGroupVersion(t *testing.T) {
+ t.Parallel()
+
+ Convey("GetEntityGroupVersion", t, func() {
+ c := memory.Use(context.Background())
+ c, fb := featureBreaker.FilterRDS(c, errors.New("INTERNAL_ERROR"))
+ ds := datastore.Get(c)
+
+ pm := datastore.PropertyMap{
+ "$key": {datastore.MkPropertyNI(ds.MakeKey("A", ""))},
+ "Val": {datastore.MkProperty(10)},
+ }
+ So(ds.Put(pm), ShouldBeNil)
+ aKey := ds.KeyForObj(pm)
+ So(aKey, ShouldNotBeNil)
+
+ v, err := GetEntityGroupVersion(c, aKey)
+ So(err, ShouldBeNil)
+ So(v, ShouldEqual, 1)
+
+ So(ds.Delete(aKey), ShouldBeNil)
+
+ v, err = GetEntityGroupVersion(c, ds.NewKey("madeUp", "thing", 0, aKey))
+ So(err, ShouldBeNil)
+ So(v, ShouldEqual, 2)
+
+ v, err = GetEntityGroupVersion(c, ds.NewKey("madeUp", "thing", 0, nil))
+ So(err, ShouldBeNil)
+ So(v, ShouldEqual, 0)
+
+ fb.BreakFeatures(nil, "GetMulti")
+
+ v, err = GetEntityGroupVersion(c, aKey)
+ So(err.Error(), ShouldContainSubstring, "INTERNAL_ERROR")
+ })
+}
« no previous file with comments | « service/datastore/meta/eg.go ('k') | service/datastore/meta/namespaces.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698