Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package meta | |
| 6 | |
| 7 import ( | |
| 8 "testing" | |
| 9 | |
| 10 "golang.org/x/net/context" | |
| 11 | |
| 12 "infra/gae/libs/wrapper" | |
| 13 "infra/gae/libs/wrapper/memory" | |
| 14 | |
| 15 . "github.com/smartystreets/goconvey/convey" | |
| 16 ) | |
| 17 | |
| 18 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
| |
| 19 Convey("GetEntityGroupVersion", t, func() { | |
| 20 c := memory.Use(memory.Enable(context.Background())) | |
| 21 ds := wrapper.GetDS(c) | |
| 22 | |
| 23 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
| |
| 24 ID int64 `datastore:"-" goon:"id"` | |
| 25 Val int | |
| 26 } | |
| 27 | |
| 28 a := &A{Val: 10} | |
| 29 aKey, err := ds.Put(a) | |
| 30 So(err, ShouldBeNil) | |
| 31 | |
| 32 v, err := GetEntityGroupVersion(c, aKey) | |
| 33 So(err, ShouldBeNil) | |
| 34 So(v, ShouldEqual, 1) | |
| 35 | |
| 36 So(ds.Delete(aKey), ShouldBeNil) | |
| 37 | |
| 38 v, err = GetEntityGroupVersion(c, ds.NewKey("madeUp", "thing", 0 , aKey)) | |
| 39 So(err, ShouldBeNil) | |
| 40 So(v, ShouldEqual, 2) | |
| 41 | |
| 42 v, err = GetEntityGroupVersion(c, ds.NewKey("madeUp", "thing", 0 , nil)) | |
| 43 So(err, ShouldBeNil) | |
| 44 So(v, ShouldEqual, 0) | |
| 45 | |
| 46 tDs := ds.(wrapper.Testable) | |
| 47 tDs.BreakFeatures(nil, "Get") | |
| 48 | |
| 49 v, err = GetEntityGroupVersion(c, aKey) | |
| 50 So(err.Error(), ShouldContainSubstring, "INTERNAL_ERROR") | |
| 51 }) | |
| 52 } | |
| OLD | NEW |