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

Side by Side Diff: service/datastore/meta/eg_test.go

Issue 2342063003: Differentiate between single- and multi- props. (Closed)
Patch Set: Slice is now always a clone. This is marginally worse performance, but a much safer UI. Created 4 years, 3 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 | « service/datastore/dumper/dumper_example_test.go ('k') | service/datastore/multiarg.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "github.com/luci/gae/service/datastore"
14 . "github.com/smartystreets/goconvey/convey" 14 . "github.com/smartystreets/goconvey/convey"
15 "golang.org/x/net/context" 15 "golang.org/x/net/context"
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 c, fb := featureBreaker.FilterRDS(c, errors.New("INTERNAL_ERROR" )) 23 c, fb := featureBreaker.FilterRDS(c, errors.New("INTERNAL_ERROR" ))
24 ds := datastore.Get(c) 24 ds := datastore.Get(c)
25 25
26 pm := datastore.PropertyMap{ 26 pm := datastore.PropertyMap{
27 » » » "$key": {datastore.MkPropertyNI(ds.MakeKey("A", ""))}, 27 » » » "$key": datastore.MkPropertyNI(ds.MakeKey("A", "")),
28 » » » "Val": {datastore.MkProperty(10)}, 28 » » » "Val": datastore.MkProperty(10),
29 } 29 }
30 So(ds.Put(pm), ShouldBeNil) 30 So(ds.Put(pm), ShouldBeNil)
31 aKey := ds.KeyForObj(pm) 31 aKey := ds.KeyForObj(pm)
32 So(aKey, ShouldNotBeNil) 32 So(aKey, ShouldNotBeNil)
33 33
34 v, err := GetEntityGroupVersion(c, aKey) 34 v, err := GetEntityGroupVersion(c, aKey)
35 So(err, ShouldBeNil) 35 So(err, ShouldBeNil)
36 So(v, ShouldEqual, 1) 36 So(v, ShouldEqual, 1)
37 37
38 So(ds.Delete(aKey), ShouldBeNil) 38 So(ds.Delete(aKey), ShouldBeNil)
39 39
40 v, err = GetEntityGroupVersion(c, ds.NewKey("madeUp", "thing", 0 , aKey)) 40 v, err = GetEntityGroupVersion(c, ds.NewKey("madeUp", "thing", 0 , aKey))
41 So(err, ShouldBeNil) 41 So(err, ShouldBeNil)
42 So(v, ShouldEqual, 2) 42 So(v, ShouldEqual, 2)
43 43
44 v, err = GetEntityGroupVersion(c, ds.NewKey("madeUp", "thing", 0 , nil)) 44 v, err = GetEntityGroupVersion(c, ds.NewKey("madeUp", "thing", 0 , nil))
45 So(err, ShouldBeNil) 45 So(err, ShouldBeNil)
46 So(v, ShouldEqual, 0) 46 So(v, ShouldEqual, 0)
47 47
48 fb.BreakFeatures(nil, "GetMulti") 48 fb.BreakFeatures(nil, "GetMulti")
49 49
50 v, err = GetEntityGroupVersion(c, aKey) 50 v, err = GetEntityGroupVersion(c, aKey)
51 So(err.Error(), ShouldContainSubstring, "INTERNAL_ERROR") 51 So(err.Error(), ShouldContainSubstring, "INTERNAL_ERROR")
52 }) 52 })
53 } 53 }
OLDNEW
« no previous file with comments | « service/datastore/dumper/dumper_example_test.go ('k') | service/datastore/multiarg.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698