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) { |
| 19 t.Parallel() |
| 20 |
| 21 Convey("GetEntityGroupVersion", t, func() { |
| 22 c := memory.Use(memory.Enable(context.Background())) |
| 23 ds := wrapper.GetDS(c) |
| 24 |
| 25 type A struct { |
| 26 ID int64 `datastore:"-" goon:"id"` |
| 27 Val int |
| 28 } |
| 29 |
| 30 a := &A{Val: 10} |
| 31 aKey, err := ds.Put(a) |
| 32 So(err, ShouldBeNil) |
| 33 |
| 34 v, err := GetEntityGroupVersion(c, aKey) |
| 35 So(err, ShouldBeNil) |
| 36 So(v, ShouldEqual, 1) |
| 37 |
| 38 So(ds.Delete(aKey), ShouldBeNil) |
| 39 |
| 40 v, err = GetEntityGroupVersion(c, ds.NewKey("madeUp", "thing", 0
, aKey)) |
| 41 So(err, ShouldBeNil) |
| 42 So(v, ShouldEqual, 2) |
| 43 |
| 44 v, err = GetEntityGroupVersion(c, ds.NewKey("madeUp", "thing", 0
, nil)) |
| 45 So(err, ShouldBeNil) |
| 46 So(v, ShouldEqual, 0) |
| 47 |
| 48 tDs := ds.(wrapper.Testable) |
| 49 tDs.BreakFeatures(nil, "Get") |
| 50 |
| 51 v, err = GetEntityGroupVersion(c, aKey) |
| 52 So(err.Error(), ShouldContainSubstring, "INTERNAL_ERROR") |
| 53 }) |
| 54 } |
OLD | NEW |