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

Side by Side Diff: impl/memory/datastore_test.go

Issue 1516173002: Fix error message from KeyForObj when passing an invalid struct. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: remove accidental extra test Created 5 years 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
OLDNEW
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 memory 5 package memory
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "testing" 9 "testing"
10 "time" 10 "time"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 So(testGetMeta(c, k), ShouldEqual, 22) 138 So(testGetMeta(c, k), ShouldEqual, 22)
139 139
140 So(ds.Put(&Foo{ID: 1}), ShouldBeNil) 140 So(ds.Put(&Foo{ID: 1}), ShouldBeNil)
141 So(testGetMeta(c, k), ShouldEqual, 23) 141 So(testGetMeta(c, k), ShouldEqual, 23)
142 }) 142 })
143 143
144 Convey("can Get", func() { 144 Convey("can Get", func() {
145 vals := make([]dsS.PropertyMap, len(keys )) 145 vals := make([]dsS.PropertyMap, len(keys ))
146 for i := range vals { 146 for i := range vals {
147 vals[i] = dsS.PropertyMap{} 147 vals[i] = dsS.PropertyMap{}
148 » » » » » » So(vals[i].SetMeta("key", keys[i ]), ShouldBeNil) 148 » » » » » » So(vals[i].SetMeta("key", keys[i ]), ShouldBeTrue)
149 } 149 }
150 So(ds.GetMulti(vals), ShouldBeNil) 150 So(ds.GetMulti(vals), ShouldBeNil)
151 151
152 for i, val := range vals { 152 for i, val := range vals {
153 So(val, ShouldResemble, dsS.Prop ertyMap{ 153 So(val, ShouldResemble, dsS.Prop ertyMap{
154 "Val": {dsS.MkProperty( 10)}, 154 "Val": {dsS.MkProperty( 10)},
155 "$key": {dsS.MkPropertyN I(keys[i])}, 155 "$key": {dsS.MkPropertyN I(keys[i])},
156 }) 156 })
157 } 157 }
158 }) 158 })
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 }, nil) 236 }, nil)
237 So(err, ShouldBeNil) 237 So(err, ShouldBeNil)
238 So(ds.Get(&Foo{ID: 1}), ShouldEqual, dsS .ErrNoSuchEntity) 238 So(ds.Get(&Foo{ID: 1}), ShouldEqual, dsS .ErrNoSuchEntity)
239 }) 239 })
240 240
241 Convey("A Get counts against your group count", func() { 241 Convey("A Get counts against your group count", func() {
242 err := ds.RunInTransaction(func(c contex t.Context) error { 242 err := ds.RunInTransaction(func(c contex t.Context) error {
243 ds := dsS.Get(c) 243 ds := dsS.Get(c)
244 244
245 pm := dsS.PropertyMap{} 245 pm := dsS.PropertyMap{}
246 » » » » » » So(pm.SetMeta("key", ds.NewKey(" Foo", "", 20, nil)), ShouldBeNil) 246 » » » » » » So(pm.SetMeta("key", ds.NewKey(" Foo", "", 20, nil)), ShouldBeTrue)
247 So(ds.Get(pm), ShouldEqual, dsS. ErrNoSuchEntity) 247 So(ds.Get(pm), ShouldEqual, dsS. ErrNoSuchEntity)
248 248
249 » » » » » » So(pm.SetMeta("key", k), ShouldB eNil) 249 » » » » » » So(pm.SetMeta("key", k), ShouldB eTrue)
250 So(ds.Get(pm).Error(), ShouldCon tainSubstring, "cross-group") 250 So(ds.Get(pm).Error(), ShouldCon tainSubstring, "cross-group")
251 return nil 251 return nil
252 }, nil) 252 }, nil)
253 So(err, ShouldBeNil) 253 So(err, ShouldBeNil)
254 }) 254 })
255 255
256 Convey("Get takes a snapshot", func() { 256 Convey("Get takes a snapshot", func() {
257 err := ds.RunInTransaction(func(c contex t.Context) error { 257 err := ds.RunInTransaction(func(c contex t.Context) error {
258 ds := dsS.Get(c) 258 ds := dsS.Get(c)
259 259
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 So(ds.Put(&Model{ID: 1, Value: []int64{20, 30}}), ShouldBeNil) 624 So(ds.Put(&Model{ID: 1, Value: []int64{20, 30}}), ShouldBeNil)
625 625
626 vals := []dsS.PropertyMap{} 626 vals := []dsS.PropertyMap{}
627 So(ds.GetAll(dsS.NewQuery("Model").Project("Value"), &vals), Sho uldBeNil) 627 So(ds.GetAll(dsS.NewQuery("Model").Project("Value"), &vals), Sho uldBeNil)
628 So(len(vals), ShouldEqual, 2) 628 So(len(vals), ShouldEqual, 2)
629 629
630 So(vals[0]["Value"][0].Value(), ShouldEqual, 20) 630 So(vals[0]["Value"][0].Value(), ShouldEqual, 20)
631 So(vals[1]["Value"][0].Value(), ShouldEqual, 30) 631 So(vals[1]["Value"][0].Value(), ShouldEqual, 30)
632 }) 632 })
633 } 633 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698