OLD | NEW |
1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
4 | 4 |
5 package meta | 5 package meta |
6 | 6 |
7 import ( | 7 import ( |
8 "errors" | 8 "errors" |
9 "testing" | 9 "testing" |
10 | 10 |
11 "github.com/luci/gae/filter/featureBreaker" | 11 "github.com/luci/gae/filter/featureBreaker" |
12 "github.com/luci/gae/impl/memory" | 12 "github.com/luci/gae/impl/memory" |
13 » "github.com/luci/gae/service/datastore" | 13 » ds "github.com/luci/gae/service/datastore" |
| 14 |
| 15 » "golang.org/x/net/context" |
| 16 |
14 . "github.com/smartystreets/goconvey/convey" | 17 . "github.com/smartystreets/goconvey/convey" |
15 "golang.org/x/net/context" | |
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()) |
23 c, fb := featureBreaker.FilterRDS(c, errors.New("INTERNAL_ERROR"
)) | 25 c, fb := featureBreaker.FilterRDS(c, errors.New("INTERNAL_ERROR"
)) |
24 ds := datastore.Get(c) | |
25 | 26 |
26 » » pm := datastore.PropertyMap{ | 27 » » pm := ds.PropertyMap{ |
27 » » » "$key": {datastore.MkPropertyNI(ds.MakeKey("A", ""))}, | 28 » » » "$key": {ds.MkPropertyNI(ds.MakeKey(c, "A", ""))}, |
28 » » » "Val": {datastore.MkProperty(10)}, | 29 » » » "Val": {ds.MkProperty(10)}, |
29 } | 30 } |
30 » » So(ds.Put(pm), ShouldBeNil) | 31 » » So(ds.Put(c, pm), ShouldBeNil) |
31 » » aKey := ds.KeyForObj(pm) | 32 » » aKey := ds.KeyForObj(c, pm) |
32 So(aKey, ShouldNotBeNil) | 33 So(aKey, ShouldNotBeNil) |
33 | 34 |
34 v, err := GetEntityGroupVersion(c, aKey) | 35 v, err := GetEntityGroupVersion(c, aKey) |
35 So(err, ShouldBeNil) | 36 So(err, ShouldBeNil) |
36 So(v, ShouldEqual, 1) | 37 So(v, ShouldEqual, 1) |
37 | 38 |
38 » » So(ds.Delete(aKey), ShouldBeNil) | 39 » » So(ds.Delete(c, aKey), ShouldBeNil) |
39 | 40 |
40 » » v, err = GetEntityGroupVersion(c, ds.NewKey("madeUp", "thing", 0
, aKey)) | 41 » » v, err = GetEntityGroupVersion(c, ds.NewKey(c, "madeUp", "thing"
, 0, aKey)) |
41 So(err, ShouldBeNil) | 42 So(err, ShouldBeNil) |
42 So(v, ShouldEqual, 2) | 43 So(v, ShouldEqual, 2) |
43 | 44 |
44 » » v, err = GetEntityGroupVersion(c, ds.NewKey("madeUp", "thing", 0
, nil)) | 45 » » v, err = GetEntityGroupVersion(c, ds.NewKey(c, "madeUp", "thing"
, 0, nil)) |
45 So(err, ShouldBeNil) | 46 So(err, ShouldBeNil) |
46 So(v, ShouldEqual, 0) | 47 So(v, ShouldEqual, 0) |
47 | 48 |
48 fb.BreakFeatures(nil, "GetMulti") | 49 fb.BreakFeatures(nil, "GetMulti") |
49 | 50 |
50 v, err = GetEntityGroupVersion(c, aKey) | 51 v, err = GetEntityGroupVersion(c, aKey) |
51 So(err.Error(), ShouldContainSubstring, "INTERNAL_ERROR") | 52 So(err.Error(), ShouldContainSubstring, "INTERNAL_ERROR") |
52 }) | 53 }) |
53 } | 54 } |
OLD | NEW |