Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: appengine/meta/eg_test.go

Issue 1400433004: Move appengine/meta lib from infra.git (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « appengine/meta/eg.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 "errors"
9 "testing"
10
11 "github.com/luci/gae/filter/featureBreaker"
12 "github.com/luci/gae/impl/memory"
13 "github.com/luci/gae/service/datastore"
14 . "github.com/smartystreets/goconvey/convey"
15 "golang.org/x/net/context"
16 )
17
18 func TestGetEntityGroupVersion(t *testing.T) {
19 t.Parallel()
20
21 Convey("GetEntityGroupVersion", t, func() {
22 c := memory.Use(context.Background())
23 c, fb := featureBreaker.FilterRDS(c, errors.New("INTERNAL_ERROR" ))
24 ds := datastore.Get(c)
25
26 pm := datastore.PropertyMap{
27 "$key": {datastore.MkPropertyNI(ds.MakeKey("A", ""))},
28 "Val": {datastore.MkProperty(10)},
29 }
30 So(ds.Put(pm), ShouldBeNil)
31 aKey, ok := pm.GetMetaDefault("key", nil).(*datastore.Key)
32 So(ok, ShouldBeTrue)
33 So(aKey, ShouldNotBeNil)
34
35 v, err := GetEntityGroupVersion(c, aKey)
36 So(err, ShouldBeNil)
37 So(v, ShouldEqual, 1)
38
39 So(ds.Delete(aKey), ShouldBeNil)
40
41 v, err = GetEntityGroupVersion(c, ds.NewKey("madeUp", "thing", 0 , aKey))
42 So(err, ShouldBeNil)
43 So(v, ShouldEqual, 2)
44
45 v, err = GetEntityGroupVersion(c, ds.NewKey("madeUp", "thing", 0 , nil))
46 So(err, ShouldBeNil)
47 So(v, ShouldEqual, 0)
48
49 fb.BreakFeatures(nil, "GetMulti")
50
51 v, err = GetEntityGroupVersion(c, aKey)
52 So(err.Error(), ShouldContainSubstring, "INTERNAL_ERROR")
53 })
54 }
OLDNEW
« no previous file with comments | « appengine/meta/eg.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698