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: service/datastore/datastore_test.go

Issue 1816413002: Make ExistsMulti return a BoolList (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Created 4 years, 9 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/datastore.go ('k') | service/datastore/interface.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 // adapted from github.com/golang/appengine/datastore 5 // adapted from github.com/golang/appengine/datastore
6 6
7 package datastore 7 package datastore
8 8
9 import ( 9 import (
10 "bytes" 10 "bytes"
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 321
322 So(pls.SetMeta("parent", k), ShouldBeTrue) 322 So(pls.SetMeta("parent", k), ShouldBeTrue)
323 So(ds.KeyForObj(pls).String(), ShouldEqual, `s~a id:ns:/Hello,"world"/CommonStruct,1`) 323 So(ds.KeyForObj(pls).String(), ShouldEqual, `s~a id:ns:/Hello,"world"/CommonStruct,1`)
324 }) 324 })
325 325
326 Convey("can see if things exist", func() { 326 Convey("can see if things exist", func() {
327 e, err := ds.Exists(k) 327 e, err := ds.Exists(k)
328 So(err, ShouldBeNil) 328 So(err, ShouldBeNil)
329 So(e, ShouldBeTrue) 329 So(e, ShouldBeTrue)
330 330
331 bl, err := ds.ExistsMulti([]*Key{k, ds.MakeKey(" hello", "other")})
332 So(err, ShouldBeNil)
333 So(bl, ShouldResemble, BoolList{true, true})
334 So(bl.All(), ShouldBeTrue)
335 So(bl.Any(), ShouldBeTrue)
336
337 bl, err = ds.ExistsMulti([]*Key{k, ds.MakeKey("D NE", "other")})
338 So(err, ShouldBeNil)
339 So(bl, ShouldResemble, BoolList{true, false})
340 So(bl.All(), ShouldBeFalse)
341 So(bl.Any(), ShouldBeTrue)
342
331 e, err = ds.Exists(ds.MakeKey("DNE", "nope")) 343 e, err = ds.Exists(ds.MakeKey("DNE", "nope"))
332 So(err, ShouldBeNil) 344 So(err, ShouldBeNil)
333 So(e, ShouldBeFalse) 345 So(e, ShouldBeFalse)
334 346
347 bl, err = ds.ExistsMulti([]*Key{ds.MakeKey("DNE" , "nope"), ds.MakeKey("DNE", "other")})
348 So(err, ShouldBeNil)
349 So(bl, ShouldResemble, BoolList{false, false})
350 So(bl.All(), ShouldBeFalse)
351 So(bl.Any(), ShouldBeFalse)
352
335 _, err = ds.Exists(ds.MakeKey("Fail", "boom")) 353 _, err = ds.Exists(ds.MakeKey("Fail", "boom"))
336 So(err, ShouldErrLike, "GetMulti fail") 354 So(err, ShouldErrLike, "GetMulti fail")
337 }) 355 })
338 356
339 }) 357 })
340 358
341 Convey("bad", func() { 359 Convey("bad", func() {
342 Convey("a propmap without $kind", func() { 360 Convey("a propmap without $kind", func() {
343 pm := PropertyMap{} 361 pm := PropertyMap{}
344 So(pm.SetMeta("id", 100), ShouldBeTrue) 362 So(pm.SetMeta("id", 100), ShouldBeTrue)
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 if err != nil { 1539 if err != nil {
1522 panic(fmt.Errorf("failed to find absolute path f or `%s`", sameLevelDir)) 1540 panic(fmt.Errorf("failed to find absolute path f or `%s`", sameLevelDir))
1523 } 1541 }
1524 1542
1525 ids, err := FindAndParseIndexYAML(abs) 1543 ids, err := FindAndParseIndexYAML(abs)
1526 So(err, ShouldBeNil) 1544 So(err, ShouldBeNil)
1527 So(ids[1].Kind, ShouldEqual, "Test Foo") 1545 So(ids[1].Kind, ShouldEqual, "Test Foo")
1528 }) 1546 })
1529 }) 1547 })
1530 } 1548 }
OLDNEW
« no previous file with comments | « service/datastore/datastore.go ('k') | service/datastore/interface.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698