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..dba9e8b1668aac53eba45e0734d687eb68fd93b5 |
--- /dev/null |
+++ b/go/src/infra/gae/libs/meta/eg_test.go |
@@ -0,0 +1,52 @@ |
+// 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) { |
M-A Ruel
2015/05/27 20:14:47
Why none of your tests are t.Parallel()?
iannucci
2015/05/27 21:36:22
because the entire test suite takes .1 seconds and
M-A Ruel
2015/05/28 22:42:38
There's two reasons;
- With Convey(), you make lar
iannucci
2015/05/28 23:00:34
Oh, that reminds me. I have half of a patch to con
|
+ Convey("GetEntityGroupVersion", t, func() { |
+ c := memory.Use(memory.Enable(context.Background())) |
+ ds := wrapper.GetDS(c) |
+ |
+ type A struct { |
M-A Ruel
2015/05/27 20:14:47
a := &struct {
...
}{Val:10}
would work fine. You
iannucci
2015/05/27 21:36:22
Put uses reflection to discover the type name. An
|
+ 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") |
+ }) |
+} |