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

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

Issue 1521823003: Clean up callback interfaces. (Closed) Base URL: https://github.com/luci/gae.git@extra
Patch Set: fixins 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
« no previous file with comments | « impl/memory/datastore_query_execution_test.go ('k') | impl/memory/gkvlite_iter.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 "fmt" 8 "fmt"
9 "testing" 9 "testing"
10 "time" 10 "time"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 }) 93 })
94 94
95 Convey("Deleting entities from a nonexistant namespace w orks", func() { 95 Convey("Deleting entities from a nonexistant namespace w orks", func() {
96 aid := infoS.Get(c).FullyQualifiedAppID() 96 aid := infoS.Get(c).FullyQualifiedAppID()
97 keys := make([]*dsS.Key, 10) 97 keys := make([]*dsS.Key, 10)
98 for i := range keys { 98 for i := range keys {
99 keys[i] = ds.MakeKey(aid, "noexist", "Ki nd", i+1) 99 keys[i] = ds.MakeKey(aid, "noexist", "Ki nd", i+1)
100 } 100 }
101 So(ds.DeleteMulti(keys), ShouldBeNil) 101 So(ds.DeleteMulti(keys), ShouldBeNil)
102 count := 0 102 count := 0
103 » » » » So(ds.Raw().DeleteMulti(keys, func(err error) { 103 » » » » So(ds.Raw().DeleteMulti(keys, func(err error) er ror {
104 count++ 104 count++
105 So(err, ShouldBeNil) 105 So(err, ShouldBeNil)
106 return nil
106 }), ShouldBeNil) 107 }), ShouldBeNil)
107 So(count, ShouldEqual, len(keys)) 108 So(count, ShouldEqual, len(keys))
108 }) 109 })
109 110
110 Convey("with multiple puts", func() { 111 Convey("with multiple puts", func() {
111 So(testGetMeta(c, k), ShouldEqual, 1) 112 So(testGetMeta(c, k), ShouldEqual, 1)
112 113
113 foos := make([]Foo, 10) 114 foos := make([]Foo, 10)
114 for i := range foos { 115 for i := range foos {
115 foos[i].Val = 10 116 foos[i].Val = 10
116 foos[i].Parent = k 117 foos[i].Parent = k
117 } 118 }
118 So(ds.PutMulti(foos), ShouldBeNil) 119 So(ds.PutMulti(foos), ShouldBeNil)
119 So(testGetMeta(c, k), ShouldEqual, 11) 120 So(testGetMeta(c, k), ShouldEqual, 11)
120 121
121 keys := make([]*dsS.Key, len(foos)) 122 keys := make([]*dsS.Key, len(foos))
122 for i, f := range foos { 123 for i, f := range foos {
123 keys[i] = ds.KeyForObj(&f) 124 keys[i] = ds.KeyForObj(&f)
124 } 125 }
125 126
126 Convey("ensure that group versions persist acros s deletes", func() { 127 Convey("ensure that group versions persist acros s deletes", func() {
127 So(ds.DeleteMulti(append(keys, k)), Shou ldBeNil) 128 So(ds.DeleteMulti(append(keys, k)), Shou ldBeNil)
128 129
129 ds.Testable().CatchupIndexes() 130 ds.Testable().CatchupIndexes()
130 131
131 count := 0 132 count := 0
132 » » » » » So(ds.Run(dsS.NewQuery(""), func(_ *dsS. Key, _ dsS.CursorCB) bool { 133 » » » » » So(ds.Run(dsS.NewQuery(""), func(_ *dsS. Key) {
133 count++ 134 count++
134 return true
135 }), ShouldBeNil) 135 }), ShouldBeNil)
136 So(count, ShouldEqual, 3) 136 So(count, ShouldEqual, 3)
137 137
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() {
(...skipping 479 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
« no previous file with comments | « impl/memory/datastore_query_execution_test.go ('k') | impl/memory/gkvlite_iter.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698