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

Side by Side Diff: service/datastore/datastore_test.go

Issue 1289323002: Fix miscellaneous prod bugs. (Closed) Base URL: https://github.com/luci/gae@master
Patch Set: Probe cache! Created 5 years, 4 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
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 "fmt" 10 "fmt"
11 "testing" 11 "testing"
12 12
13 "github.com/luci/gae/service/info" 13 "github.com/luci/gae/service/info"
14 "github.com/luci/luci-go/common/errors" 14 "github.com/luci/luci-go/common/errors"
15 . "github.com/smartystreets/goconvey/convey" 15 . "github.com/smartystreets/goconvey/convey"
16 "golang.org/x/net/context" 16 "golang.org/x/net/context"
17 ) 17 )
18 18
19 func fakeDatastoreFactory(c context.Context) RawInterface { 19 func fakeDatastoreFactory(c context.Context) RawInterface {
20 i := info.Get(c) 20 i := info.Get(c)
21 return &fakeDatastore{ 21 return &fakeDatastore{
22 » » aid: i.AppID(), 22 » » aid: i.FullyQualifiedAppID(),
23 ns: i.GetNamespace(), 23 ns: i.GetNamespace(),
24 } 24 }
25 } 25 }
26 26
27 type fakeQuery struct { 27 type fakeQuery struct {
28 Query 28 Query
29 29
30 limit int 30 limit int
31 31
32 err error 32 err error
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 541
542 Convey("Test Delete/DeleteMulti", t, func() { 542 Convey("Test Delete/DeleteMulti", t, func() {
543 c := info.Set(context.Background(), fakeInfo{}) 543 c := info.Set(context.Background(), fakeInfo{})
544 c = SetRawFactory(c, fakeDatastoreFactory) 544 c = SetRawFactory(c, fakeDatastoreFactory)
545 ds := Get(c) 545 ds := Get(c)
546 So(ds, ShouldNotBeNil) 546 So(ds, ShouldNotBeNil)
547 547
548 Convey("bad", func() { 548 Convey("bad", func() {
549 Convey("get single error for RPC failure", func() { 549 Convey("get single error for RPC failure", func() {
550 keys := []Key{ 550 keys := []Key{
551 » » » » » NewKey("aid", "ns", "FailAll", "", 1, ni l), 551 » » » » » NewKey("s~aid", "ns", "FailAll", "", 1, nil),
552 » » » » » NewKey("aid", "ns", "Ok", "", 1, nil), 552 » » » » » NewKey("s~aid", "ns", "Ok", "", 1, nil),
553 } 553 }
554 So(ds.DeleteMulti(keys).Error(), ShouldEqual, "D eleteMulti fail all") 554 So(ds.DeleteMulti(keys).Error(), ShouldEqual, "D eleteMulti fail all")
555 }) 555 })
556 556
557 Convey("get multi error for individual failure", func() { 557 Convey("get multi error for individual failure", func() {
558 keys := []Key{ 558 keys := []Key{
559 ds.NewKey("Ok", "", 1, nil), 559 ds.NewKey("Ok", "", 1, nil),
560 ds.NewKey("Fail", "", 2, nil), 560 ds.NewKey("Fail", "", 2, nil),
561 } 561 }
562 So(ds.DeleteMulti(keys).Error(), ShouldEqual, "D eleteMulti fail") 562 So(ds.DeleteMulti(keys).Error(), ShouldEqual, "D eleteMulti fail")
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 So(ds.Run(q, func(k Key, _ CursorCB) bool { 890 So(ds.Run(q, func(k Key, _ CursorCB) bool {
891 So(k.IntID(), ShouldEqual, i+1) 891 So(k.IntID(), ShouldEqual, i+1)
892 i++ 892 i++
893 return true 893 return true
894 }), ShouldBeNil) 894 }), ShouldBeNil)
895 }) 895 })
896 896
897 }) 897 })
898 }) 898 })
899 } 899 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698