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 "errors" |
8 "testing" | 9 "testing" |
9 | 10 |
10 "golang.org/x/net/context" | 11 "golang.org/x/net/context" |
11 | 12 |
12 "infra/gae/libs/gae" | 13 "infra/gae/libs/gae" |
| 14 "infra/gae/libs/gae/filters/featureBreaker" |
13 "infra/gae/libs/gae/memory" | 15 "infra/gae/libs/gae/memory" |
14 | 16 |
15 . "github.com/smartystreets/goconvey/convey" | 17 . "github.com/smartystreets/goconvey/convey" |
16 ) | 18 ) |
17 | 19 |
18 func TestGetEntityGroupVersion(t *testing.T) { | 20 func TestGetEntityGroupVersion(t *testing.T) { |
19 t.Parallel() | 21 t.Parallel() |
20 | 22 |
21 Convey("GetEntityGroupVersion", t, func() { | 23 Convey("GetEntityGroupVersion", t, func() { |
22 c := memory.Use(context.Background()) | 24 c := memory.Use(context.Background()) |
| 25 c, fb := featureBreaker.FilterRDS(c, errors.New("INTERNAL_ERROR"
)) |
23 rds := gae.GetRDS(c) | 26 rds := gae.GetRDS(c) |
24 | 27 |
25 aKey, err := rds.Put(rds.NewKey("A", "", 0, nil), gae.DSProperty
Map{ | 28 aKey, err := rds.Put(rds.NewKey("A", "", 0, nil), gae.DSProperty
Map{ |
26 "Val": {gae.MkDSProperty(10)}, | 29 "Val": {gae.MkDSProperty(10)}, |
27 }) | 30 }) |
28 So(err, ShouldBeNil) | 31 So(err, ShouldBeNil) |
29 | 32 |
30 v, err := GetEntityGroupVersion(c, aKey) | 33 v, err := GetEntityGroupVersion(c, aKey) |
31 So(err, ShouldBeNil) | 34 So(err, ShouldBeNil) |
32 So(v, ShouldEqual, 1) | 35 So(v, ShouldEqual, 1) |
33 | 36 |
34 So(rds.Delete(aKey), ShouldBeNil) | 37 So(rds.Delete(aKey), ShouldBeNil) |
35 | 38 |
36 v, err = GetEntityGroupVersion(c, rds.NewKey("madeUp", "thing",
0, aKey)) | 39 v, err = GetEntityGroupVersion(c, rds.NewKey("madeUp", "thing",
0, aKey)) |
37 So(err, ShouldBeNil) | 40 So(err, ShouldBeNil) |
38 So(v, ShouldEqual, 2) | 41 So(v, ShouldEqual, 2) |
39 | 42 |
40 v, err = GetEntityGroupVersion(c, rds.NewKey("madeUp", "thing",
0, nil)) | 43 v, err = GetEntityGroupVersion(c, rds.NewKey("madeUp", "thing",
0, nil)) |
41 So(err, ShouldBeNil) | 44 So(err, ShouldBeNil) |
42 So(v, ShouldEqual, 0) | 45 So(v, ShouldEqual, 0) |
43 | 46 |
44 » » tDs := rds.(gae.Testable) | 47 » » fb.BreakFeatures(nil, "Get") |
45 » » tDs.BreakFeatures(nil, "Get") | |
46 | 48 |
47 v, err = GetEntityGroupVersion(c, aKey) | 49 v, err = GetEntityGroupVersion(c, aKey) |
48 So(err.Error(), ShouldContainSubstring, "INTERNAL_ERROR") | 50 So(err.Error(), ShouldContainSubstring, "INTERNAL_ERROR") |
49 }) | 51 }) |
50 } | 52 } |
OLD | NEW |