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

Unified Diff: go/src/infra/gae/libs/meta/eg_test.go

Issue 1152383003: Simple memory testing for gae/wrapper (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@better_context_lite
Patch Set: add go-slab dependency Created 5 years, 7 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 | « go/Goopfile.lock ('k') | go/src/infra/gae/libs/meta/meta.infra_testing » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/gae/libs/meta/eg_test.go
diff --git a/go/src/infra/gae/libs/meta/eg_test.go b/go/src/infra/gae/libs/meta/eg_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..8abb102ca30648e39967385b1a9de4c50098db8f
--- /dev/null
+++ b/go/src/infra/gae/libs/meta/eg_test.go
@@ -0,0 +1,54 @@
+// 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 (
+ "testing"
+
+ "golang.org/x/net/context"
+
+ "infra/gae/libs/wrapper"
+ "infra/gae/libs/wrapper/memory"
+
+ . "github.com/smartystreets/goconvey/convey"
+)
+
+func TestGetEntityGroupVersion(t *testing.T) {
+ t.Parallel()
+
+ Convey("GetEntityGroupVersion", t, func() {
+ c := memory.Use(memory.Enable(context.Background()))
+ ds := wrapper.GetDS(c)
+
+ type A struct {
+ ID int64 `datastore:"-" goon:"id"`
+ Val int
+ }
+
+ a := &A{Val: 10}
+ aKey, err := ds.Put(a)
+ So(err, ShouldBeNil)
+
+ 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)
+
+ tDs := ds.(wrapper.Testable)
+ tDs.BreakFeatures(nil, "Get")
+
+ v, err = GetEntityGroupVersion(c, aKey)
+ So(err.Error(), ShouldContainSubstring, "INTERNAL_ERROR")
+ })
+}
« no previous file with comments | « go/Goopfile.lock ('k') | go/src/infra/gae/libs/meta/meta.infra_testing » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698