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