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

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

Issue 1844183003: Don't filter "Stop" error in raw interface. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Count filter doesn't count Stop as error. Created 4 years, 8 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 | « impl/memory/gkvlite_iter.go ('k') | impl/prod/raw_datastore.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 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 "bytes" 8 "bytes"
9 "testing" 9 "testing"
10 10
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 defs := []*iterDefinition{ 207 defs := []*iterDefinition{
208 {c: c, prefix: mkNum(1), prefixLen: len(mkNum(1) ), start: mkNum(2), end: mkNum(7)}, 208 {c: c, prefix: mkNum(1), prefixLen: len(mkNum(1) ), start: mkNum(2), end: mkNum(7)},
209 {c: c, prefix: mkNum(1), prefixLen: len(mkNum(1) ), start: mkNum(2), end: mkNum(7)}, 209 {c: c, prefix: mkNum(1), prefixLen: len(mkNum(1) ), start: mkNum(2), end: mkNum(7)},
210 } 210 }
211 211
212 i := 1 212 i := 1
213 So(multiIterate(defs, func(suffix []byte) error { 213 So(multiIterate(defs, func(suffix []byte) error {
214 So(readNum(suffix), ShouldEqual, vals[i][1]) 214 So(readNum(suffix), ShouldEqual, vals[i][1])
215 i++ 215 i++
216 return nil 216 return nil
217 » » » }), ShouldBeNil) 217 » » » }), shouldBeSuccessful)
218 218
219 So(i, ShouldEqual, 3) 219 So(i, ShouldEqual, 3)
220 }) 220 })
221 221
222 Convey("can make empty iteration", func() { 222 Convey("can make empty iteration", func() {
223 // get just the (20, *) (doesn't exist) 223 // get just the (20, *) (doesn't exist)
224 defs := []*iterDefinition{ 224 defs := []*iterDefinition{
225 {c: c, prefix: mkNum(20)}, 225 {c: c, prefix: mkNum(20)},
226 {c: c, prefix: mkNum(20)}, 226 {c: c, prefix: mkNum(20)},
227 } 227 }
228 228
229 i := 0 229 i := 0
230 So(multiIterate(defs, func(suffix []byte) error { 230 So(multiIterate(defs, func(suffix []byte) error {
231 panic("never") 231 panic("never")
232 » » » }), ShouldBeNil) 232 » » » }), shouldBeSuccessful)
233 233
234 So(i, ShouldEqual, 0) 234 So(i, ShouldEqual, 0)
235 }) 235 })
236 236
237 Convey("can join (other, val, val)", func() { 237 Convey("can join (other, val, val)", func() {
238 // 'other' must start with 20, 'vals' must start with 1 238 // 'other' must start with 20, 'vals' must start with 1
239 // no range constraints 239 // no range constraints
240 defs := []*iterDefinition{ 240 defs := []*iterDefinition{
241 {c: c2, prefix: mkNum(20)}, 241 {c: c2, prefix: mkNum(20)},
242 {c: c, prefix: mkNum(1)}, 242 {c: c, prefix: mkNum(1)},
243 {c: c, prefix: mkNum(1)}, 243 {c: c, prefix: mkNum(1)},
244 } 244 }
245 245
246 expect := []int64{2, 4} 246 expect := []int64{2, 4}
247 i := 0 247 i := 0
248 So(multiIterate(defs, func(suffix []byte) error { 248 So(multiIterate(defs, func(suffix []byte) error {
249 So(readNum(suffix), ShouldEqual, expect[i]) 249 So(readNum(suffix), ShouldEqual, expect[i])
250 i++ 250 i++
251 return nil 251 return nil
252 » » » }), ShouldBeNil) 252 » » » }), shouldBeSuccessful)
253 }) 253 })
254 254
255 Convey("Can stop early", func() { 255 Convey("Can stop early", func() {
256 defs := []*iterDefinition{ 256 defs := []*iterDefinition{
257 {c: c, prefix: mkNum(1), prefixLen: len(mkNum(1) )}, 257 {c: c, prefix: mkNum(1), prefixLen: len(mkNum(1) )},
258 {c: c, prefix: mkNum(1), prefixLen: len(mkNum(1) )}, 258 {c: c, prefix: mkNum(1), prefixLen: len(mkNum(1) )},
259 } 259 }
260 260
261 i := 0 261 i := 0
262 So(multiIterate(defs, func(suffix []byte) error { 262 So(multiIterate(defs, func(suffix []byte) error {
263 So(readNum(suffix), ShouldEqual, vals[i][1]) 263 So(readNum(suffix), ShouldEqual, vals[i][1])
264 i++ 264 i++
265 return nil 265 return nil
266 » » » }), ShouldBeNil) 266 » » » }), shouldBeSuccessful)
267 So(i, ShouldEqual, 5) 267 So(i, ShouldEqual, 5)
268 268
269 i = 0 269 i = 0
270 So(multiIterate(defs, func(suffix []byte) error { 270 So(multiIterate(defs, func(suffix []byte) error {
271 So(readNum(suffix), ShouldEqual, vals[i][1]) 271 So(readNum(suffix), ShouldEqual, vals[i][1])
272 i++ 272 i++
273 return datastore.Stop 273 return datastore.Stop
274 » » » }), ShouldBeNil) 274 » » » }), shouldBeSuccessful)
275 So(i, ShouldEqual, 1) 275 So(i, ShouldEqual, 1)
276 }) 276 })
277 277
278 }) 278 })
279 279
280 } 280 }
OLDNEW
« no previous file with comments | « impl/memory/gkvlite_iter.go ('k') | impl/prod/raw_datastore.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698