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

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

Issue 1302813003: impl/memory: Implement Queries (Closed) Base URL: https://github.com/luci/gae.git@add_multi_iterator
Patch Set: inequalities work now 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 package memory 5 package memory
6 6
7 import ( 7 import (
8 "testing" 8 "testing"
9 "time" 9 "time"
10 10
11 ds "github.com/luci/gae/service/datastore" 11 ds "github.com/luci/gae/service/datastore"
12 "github.com/luci/gkvlite" 12 "github.com/luci/gkvlite"
13 . "github.com/smartystreets/goconvey/convey" 13 . "github.com/smartystreets/goconvey/convey"
14 ) 14 )
15 15
16 func init() {
17 indexCreationDeterministic = true
18 }
19
20 var fakeKey = key("knd", 10, key("parentKind", "sid")) 16 var fakeKey = key("knd", 10, key("parentKind", "sid"))
21 17
22 func TestCollated(t *testing.T) { 18 func TestCollated(t *testing.T) {
23 t.Parallel() 19 t.Parallel()
24 20
25 Convey("TestCollated", t, func() { 21 Convey("TestCollated", t, func() {
26 Convey("nil list", func() { 22 Convey("nil list", func() {
27 » » » pm := (ds.PropertyMap)(nil) 23 » » » pm := ds.PropertyMap(nil)
28 » » » sip := partiallySerialize(pm) 24 » » » sip := partiallySerialize(fakeKey, pm)
29 » » » So(sip, ShouldBeNil)
30 25
31 Convey("nil collated", func() { 26 Convey("nil collated", func() {
32 Convey("defaultIndicies", func() { 27 Convey("defaultIndicies", func() {
33 idxs := defaultIndicies("knd", pm) 28 idxs := defaultIndicies("knd", pm)
34 So(len(idxs), ShouldEqual, 1) 29 So(len(idxs), ShouldEqual, 1)
35 So(idxs[0].String(), ShouldEqual, "B:knd ") 30 So(idxs[0].String(), ShouldEqual, "B:knd ")
36 }) 31 })
37 Convey("indexEntries", func() { 32 Convey("indexEntries", func() {
38 » » » » » s := sip.indexEntries(fakeKey, defaultIn dicies("knd", pm)) 33 » » » » » s := sip.indexEntries("ns", defaultIndic ies("knd", pm))
39 numItems, _ := s.GetCollection("idx").Ge tTotals() 34 numItems, _ := s.GetCollection("idx").Ge tTotals()
40 So(numItems, ShouldEqual, 1) 35 So(numItems, ShouldEqual, 1)
41 itm := s.GetCollection("idx").MinItem(fa lse) 36 itm := s.GetCollection("idx").MinItem(fa lse)
42 So(itm.Key, ShouldResemble, cat(indx("kn d"))) 37 So(itm.Key, ShouldResemble, cat(indx("kn d")))
43 numItems, _ = s.GetCollection("idx:ns:" + string(itm.Key)).GetTotals() 38 numItems, _ = s.GetCollection("idx:ns:" + string(itm.Key)).GetTotals()
44 So(numItems, ShouldEqual, 1) 39 So(numItems, ShouldEqual, 1)
45 }) 40 })
46 }) 41 })
47 }) 42 })
48 43
49 Convey("list", func() { 44 Convey("list", func() {
50 pm := ds.PropertyMap{ 45 pm := ds.PropertyMap{
51 "wat": {propNI("thing"), prop("hat"), prop(100) }, 46 "wat": {propNI("thing"), prop("hat"), prop(100) },
52 "nerd": {prop(103.7)}, 47 "nerd": {prop(103.7)},
53 "spaz": {propNI(false)}, 48 "spaz": {propNI(false)},
54 } 49 }
55 » » » sip := partiallySerialize(pm) 50 » » » sip := partiallySerialize(fakeKey, pm)
56 » » » So(len(sip), ShouldEqual, 2) 51 » » » So(len(sip), ShouldEqual, 4)
57 52
58 Convey("single collated", func() { 53 Convey("single collated", func() {
59 Convey("indexableMap", func() { 54 Convey("indexableMap", func() {
60 So(sip, ShouldResemble, serializedIndexa blePmap{ 55 So(sip, ShouldResemble, serializedIndexa blePmap{
61 "wat": { 56 "wat": {
62 » » » » » » » cat(ds.PTInt, 100), 57 » » » » » » » cat(prop(100)),
63 » » » » » » » cat(ds.PTString, "hat"), 58 » » » » » » » cat(prop("hat")),
64 // 'thing' is skipped, b ecause it's not NoIndex 59 // 'thing' is skipped, b ecause it's not NoIndex
65 }, 60 },
66 "nerd": { 61 "nerd": {
67 » » » » » » » cat(ds.PTFloat, 103.7), 62 » » » » » » » cat(prop(103.7)),
63 » » » » » » },
64 » » » » » » "__key__": {
65 » » » » » » » cat(prop(fakeKey)),
66 » » » » » » },
67 » » » » » » "__ancestor__": {
68 » » » » » » » cat(prop(fakeKey)),
69 » » » » » » » cat(prop(fakeKey.Parent( ))),
68 }, 70 },
69 }) 71 })
70 }) 72 })
71 Convey("defaultIndicies", func() { 73 Convey("defaultIndicies", func() {
72 idxs := defaultIndicies("knd", pm) 74 idxs := defaultIndicies("knd", pm)
73 So(len(idxs), ShouldEqual, 5) 75 So(len(idxs), ShouldEqual, 5)
74 So(idxs[0].String(), ShouldEqual, "B:knd ") 76 So(idxs[0].String(), ShouldEqual, "B:knd ")
75 So(idxs[1].String(), ShouldEqual, "B:knd /nerd") 77 So(idxs[1].String(), ShouldEqual, "B:knd /nerd")
76 So(idxs[2].String(), ShouldEqual, "B:knd /wat") 78 So(idxs[2].String(), ShouldEqual, "B:knd /wat")
77 So(idxs[3].String(), ShouldEqual, "B:knd /-nerd") 79 So(idxs[3].String(), ShouldEqual, "B:knd /-nerd")
(...skipping 12 matching lines...) Expand all
90 name string 92 name string
91 pmap ds.PropertyMap 93 pmap ds.PropertyMap
92 withBuiltin bool 94 withBuiltin bool
93 idxs []*ds.IndexDefinition 95 idxs []*ds.IndexDefinition
94 96
95 // These are checked in TestIndexRowGen. nil to skip test case. 97 // These are checked in TestIndexRowGen. nil to skip test case.
96 expected []serializedPvals 98 expected []serializedPvals
97 99
98 // just the collections you want to assert. These are checked in 100 // just the collections you want to assert. These are checked in
99 // TestIndexEntries. nil to skip test case. 101 // TestIndexEntries. nil to skip test case.
100 » collections map[string][]kv 102 » collections map[string][][]byte
101 }{ 103 }{
104
102 { 105 {
103 name: "simple including builtins", 106 name: "simple including builtins",
104 pmap: ds.PropertyMap{ 107 pmap: ds.PropertyMap{
105 "wat": {propNI("thing"), prop("hat"), prop(100)}, 108 "wat": {propNI("thing"), prop("hat"), prop(100)},
106 "nerd": {prop(103.7)}, 109 "nerd": {prop(103.7)},
107 "spaz": {propNI(false)}, 110 "spaz": {propNI(false)},
108 }, 111 },
109 withBuiltin: true, 112 withBuiltin: true,
110 idxs: []*ds.IndexDefinition{ 113 idxs: []*ds.IndexDefinition{
111 indx("knd", "-wat", "nerd"), 114 indx("knd", "-wat", "nerd"),
112 }, 115 },
113 expected: []serializedPvals{ 116 expected: []serializedPvals{
114 » » » {{}}, // B:knd 117 » » » {cat(prop(fakeKey))}, // B:knd
115 » » » {cat(ds.PTFloat, 103.7)}, // B:kn d/nerd 118 » » » {cat(prop(103.7), prop(fakeKey))}, // B:knd/nerd
116 » » » {cat(ds.PTInt, 100), cat(ds.PTString, "hat")}, // B:kn d/wat 119 » » » { // B:knd/wat
117 » » » {icat(ds.PTFloat, 103.7)}, // B:kn d/-nerd 120 » » » » cat(prop(100), prop(fakeKey)),
118 » » » {icat(ds.PTString, "hat"), icat(ds.PTInt, 100)}, // B:kn d/-wat 121 » » » » cat(prop("hat"), prop(fakeKey)),
122 » » » },
123 » » » { // B:knd/-nerd
124 » » » » cat(icat(prop(103.7)), prop(fakeKey)),
125 » » » },
126 » » » { // B:knd/-wat
127 » » » » cat(icat(prop("hat")), prop(fakeKey)),
128 » » » » cat(icat(prop(100)), prop(fakeKey)),
129 » » » },
119 { // C:knd/-wat/nerd 130 { // C:knd/-wat/nerd
120 » » » » cat(icat(ds.PTString, "hat"), cat(ds.PTFloat, 10 3.7)), 131 » » » » cat(icat(prop("hat")), prop(103.7), prop(fakeKey )),
121 » » » » cat(icat(ds.PTInt, 100), cat(ds.PTFloat, 103.7)) , 132 » » » » cat(icat(prop(100)), prop(103.7), prop(fakeKey)) ,
122 }, 133 },
123 }, 134 },
124 » » collections: map[string][]kv{ 135
136 » » collections: map[string][][]byte{
125 "idx": { 137 "idx": {
126 // 0 == builtin, 1 == complex 138 // 0 == builtin, 1 == complex
127 » » » » {cat(byte(0), "knd", byte(0), 0), []byte{}}, 139 » » » » cat(byte(0), "knd", byte(0), 0),
128 » » » » {cat(byte(0), "knd", byte(0), 1, byte(0), "nerd" ), []byte{}}, 140 » » » » cat(byte(0), "knd", byte(0), 1, byte(0), "nerd") ,
129 » » » » {cat(byte(0), "knd", byte(0), 1, byte(0), "wat") , []byte{}}, 141 » » » » cat(byte(0), "knd", byte(0), 1, byte(0), "wat"),
130 » » » » {cat(byte(0), "knd", byte(0), 1, byte(1), "nerd" ), []byte{}}, 142 » » » » cat(byte(0), "knd", byte(0), 1, byte(1), "nerd") ,
131 » » » » {cat(byte(0), "knd", byte(0), 1, byte(1), "wat") , []byte{}}, 143 » » » » cat(byte(0), "knd", byte(0), 1, byte(1), "wat"),
132 » » » » {cat(byte(1), "knd", byte(0), 2, byte(1), "wat", byte(0), "nerd"), []byte{}}, 144 » » » » cat(byte(1), "knd", byte(0), 2, byte(1), "wat", byte(0), "nerd"),
133 }, 145 },
134 "idx:ns:" + sat(indx("knd")): { 146 "idx:ns:" + sat(indx("knd")): {
135 » » » » {cat(fakeKey), []byte{}}, 147 » » » » cat(prop(fakeKey)),
136 }, 148 },
137 "idx:ns:" + sat(indx("knd", "wat")): { 149 "idx:ns:" + sat(indx("knd", "wat")): {
138 » » » » {cat(ds.PTInt, 100, fakeKey), []byte{}}, 150 » » » » cat(prop(100), prop(fakeKey)),
139 » » » » {cat(ds.PTString, "hat", fakeKey), cat(ds.PTInt, 100)}, 151 » » » » cat(prop("hat"), prop(fakeKey)),
140 }, 152 },
141 "idx:ns:" + sat(indx("knd", "-wat")): { 153 "idx:ns:" + sat(indx("knd", "-wat")): {
142 » » » » {cat(icat(ds.PTString, "hat"), fakeKey), []byte{ }}, 154 » » » » cat(icat(prop("hat")), prop(fakeKey)),
143 » » » » {cat(icat(ds.PTInt, 100), fakeKey), icat(ds.PTSt ring, "hat")}, 155 » » » » cat(icat(prop(100)), prop(fakeKey)),
144 }, 156 },
145 }, 157 },
146 }, 158 },
159
147 { 160 {
148 name: "complex", 161 name: "complex",
149 pmap: ds.PropertyMap{ 162 pmap: ds.PropertyMap{
150 "yerp": {prop("hat"), prop(73.9)}, 163 "yerp": {prop("hat"), prop(73.9)},
151 "wat": { 164 "wat": {
152 prop(rgenComplexTime), 165 prop(rgenComplexTime),
153 prop(ds.ByteString("value")), 166 prop(ds.ByteString("value")),
154 prop(rgenComplexKey)}, 167 prop(rgenComplexKey)},
155 "spaz": {prop(nil), prop(false), prop(true)}, 168 "spaz": {prop(nil), prop(false), prop(true)},
156 }, 169 },
157 idxs: []*ds.IndexDefinition{ 170 idxs: []*ds.IndexDefinition{
158 indx("knd", "-wat", "nerd", "spaz"), // doesn't match, s o empty 171 indx("knd", "-wat", "nerd", "spaz"), // doesn't match, s o empty
159 indx("knd", "yerp", "-wat", "spaz"), 172 indx("knd", "yerp", "-wat", "spaz"),
160 }, 173 },
161 expected: []serializedPvals{ 174 expected: []serializedPvals{
162 {}, // C:knd/-wat/nerd/spaz, no match 175 {}, // C:knd/-wat/nerd/spaz, no match
163 { // C:knd/yerp/-wat/spaz 176 { // C:knd/yerp/-wat/spaz
164 // thank goodness the binary serialization only happens 1/val in the 177 // thank goodness the binary serialization only happens 1/val in the
165 // real code :). 178 // real code :).
166 » » » » cat(cat(ds.PTString, "hat"), icat(ds.PTKey, rgen ComplexKey), cat(ds.PTNull)), 179 » » » » cat(prop("hat"), icat(prop(rgenComplexKey)), pro p(nil), prop(fakeKey)),
167 » » » » cat(cat(ds.PTString, "hat"), icat(ds.PTKey, rgen ComplexKey), cat(ds.PTBoolFalse)), 180 » » » » cat(prop("hat"), icat(prop(rgenComplexKey)), pro p(false), prop(fakeKey)),
168 » » » » cat(cat(ds.PTString, "hat"), icat(ds.PTKey, rgen ComplexKey), cat(ds.PTBoolTrue)), 181 » » » » cat(prop("hat"), icat(prop(rgenComplexKey)), pro p(true), prop(fakeKey)),
169 » » » » cat(cat(ds.PTString, "hat"), icat(ds.PTBytes, "v alue"), cat(ds.PTNull)), 182 » » » » cat(prop("hat"), icat(prop(ds.ByteString("value" ))), prop(nil), prop(fakeKey)),
170 » » » » cat(cat(ds.PTString, "hat"), icat(ds.PTBytes, "v alue"), cat(ds.PTBoolFalse)), 183 » » » » cat(prop("hat"), icat(prop(ds.ByteString("value" ))), prop(false), prop(fakeKey)),
171 » » » » cat(cat(ds.PTString, "hat"), icat(ds.PTBytes, "v alue"), cat(ds.PTBoolTrue)), 184 » » » » cat(prop("hat"), icat(prop(ds.ByteString("value" ))), prop(true), prop(fakeKey)),
172 » » » » cat(cat(ds.PTString, "hat"), icat(ds.PTTime, rge nComplexTime), cat(ds.PTNull)), 185 » » » » cat(prop("hat"), icat(prop(rgenComplexTime)), pr op(nil), prop(fakeKey)),
173 » » » » cat(cat(ds.PTString, "hat"), icat(ds.PTTime, rge nComplexTime), cat(ds.PTBoolFalse)), 186 » » » » cat(prop("hat"), icat(prop(rgenComplexTime)), pr op(false), prop(fakeKey)),
174 » » » » cat(cat(ds.PTString, "hat"), icat(ds.PTTime, rge nComplexTime), cat(ds.PTBoolTrue)), 187 » » » » cat(prop("hat"), icat(prop(rgenComplexTime)), pr op(true), prop(fakeKey)),
175 188
176 » » » » cat(cat(ds.PTFloat, 73.9), icat(ds.PTKey, rgenCo mplexKey), cat(ds.PTNull)), 189 » » » » cat(prop(73.9), icat(prop(rgenComplexKey)), prop (nil), prop(fakeKey)),
177 » » » » cat(cat(ds.PTFloat, 73.9), icat(ds.PTKey, rgenCo mplexKey), cat(ds.PTBoolFalse)), 190 » » » » cat(prop(73.9), icat(prop(rgenComplexKey)), prop (false), prop(fakeKey)),
178 » » » » cat(cat(ds.PTFloat, 73.9), icat(ds.PTKey, rgenCo mplexKey), cat(ds.PTBoolTrue)), 191 » » » » cat(prop(73.9), icat(prop(rgenComplexKey)), prop (true), prop(fakeKey)),
179 » » » » cat(cat(ds.PTFloat, 73.9), icat(ds.PTBytes, "val ue"), cat(ds.PTNull)), 192 » » » » cat(prop(73.9), icat(prop(ds.ByteString("value") )), prop(nil), prop(fakeKey)),
180 » » » » cat(cat(ds.PTFloat, 73.9), icat(ds.PTBytes, "val ue"), cat(ds.PTBoolFalse)), 193 » » » » cat(prop(73.9), icat(prop(ds.ByteString("value") )), prop(false), prop(fakeKey)),
181 » » » » cat(cat(ds.PTFloat, 73.9), icat(ds.PTBytes, "val ue"), cat(ds.PTBoolTrue)), 194 » » » » cat(prop(73.9), icat(prop(ds.ByteString("value") )), prop(true), prop(fakeKey)),
182 » » » » cat(cat(ds.PTFloat, 73.9), icat(ds.PTTime, rgenC omplexTime), cat(ds.PTNull)), 195 » » » » cat(prop(73.9), icat(prop(rgenComplexTime)), pro p(nil), prop(fakeKey)),
183 » » » » cat(cat(ds.PTFloat, 73.9), icat(ds.PTTime, rgenC omplexTime), cat(ds.PTBoolFalse)), 196 » » » » cat(prop(73.9), icat(prop(rgenComplexTime)), pro p(false), prop(fakeKey)),
184 » » » » cat(cat(ds.PTFloat, 73.9), icat(ds.PTTime, rgenC omplexTime), cat(ds.PTBoolTrue)), 197 » » » » cat(prop(73.9), icat(prop(rgenComplexTime)), pro p(true), prop(fakeKey)),
185 }, 198 },
186 }, 199 },
187 }, 200 },
201
188 { 202 {
189 name: "ancestor", 203 name: "ancestor",
190 pmap: ds.PropertyMap{ 204 pmap: ds.PropertyMap{
191 "wat": {prop("sup")}, 205 "wat": {prop("sup")},
192 }, 206 },
193 idxs: []*ds.IndexDefinition{ 207 idxs: []*ds.IndexDefinition{
194 indx("knd!", "wat"), 208 indx("knd!", "wat"),
195 }, 209 },
196 » » collections: map[string][]kv{ 210 » » collections: map[string][][]byte{
197 "idx:ns:" + sat(indx("knd!", "wat")): { 211 "idx:ns:" + sat(indx("knd!", "wat")): {
198 » » » » {cat(fakeKey.Parent(), ds.PTString, "sup", fakeK ey), []byte{}}, 212 » » » » cat(prop(fakeKey.Parent()), prop("sup"), prop(fa keKey)),
199 » » » » {cat(fakeKey, ds.PTString, "sup", fakeKey), []by te{}}, 213 » » » » cat(prop(fakeKey), prop("sup"), prop(fakeKey)),
200 }, 214 },
201 }, 215 },
202 }, 216 },
203 } 217 }
204 218
205 func TestIndexRowGen(t *testing.T) { 219 func TestIndexRowGen(t *testing.T) {
206 t.Parallel() 220 t.Parallel()
207 221
208 Convey("Test Index Row Generation", t, func() { 222 Convey("Test Index Row Generation", t, func() {
209 for _, tc := range rowGenTestCases { 223 for _, tc := range rowGenTestCases {
210 if tc.expected == nil { 224 if tc.expected == nil {
211 Convey(tc.name, nil) // shows up as 'skipped' 225 Convey(tc.name, nil) // shows up as 'skipped'
212 continue 226 continue
213 } 227 }
214 228
215 Convey(tc.name, func() { 229 Convey(tc.name, func() {
216 » » » » mvals := partiallySerialize(tc.pmap) 230 » » » » mvals := partiallySerialize(fakeKey, tc.pmap)
217 idxs := []*ds.IndexDefinition(nil) 231 idxs := []*ds.IndexDefinition(nil)
218 if tc.withBuiltin { 232 if tc.withBuiltin {
219 idxs = append(defaultIndicies("coolKind" , tc.pmap), tc.idxs...) 233 idxs = append(defaultIndicies("coolKind" , tc.pmap), tc.idxs...)
220 } else { 234 } else {
221 idxs = tc.idxs 235 idxs = tc.idxs
222 } 236 }
223 237
224 m := matcher{} 238 m := matcher{}
225 for i, idx := range idxs { 239 for i, idx := range idxs {
226 Convey(idx.String(), func() { 240 Convey(idx.String(), func() {
227 » » » » » » iGen, ok := m.match(idx, mvals) 241 » » » » » » iGen, ok := m.match(idx.Normaliz eOrder(), mvals)
228 if len(tc.expected[i]) > 0 { 242 if len(tc.expected[i]) > 0 {
229 So(ok, ShouldBeTrue) 243 So(ok, ShouldBeTrue)
230 j := 0 244 j := 0
231 » » » » » » » iGen.permute(func(row [] byte) { 245 » » » » » » » iGen.permute(func(row, _ []byte) {
232 So([]byte(row), ShouldResemble, tc.expected[i][j]) 246 So([]byte(row), ShouldResemble, tc.expected[i][j])
233 j++ 247 j++
234 }) 248 })
235 So(j, ShouldEqual, len(t c.expected[i])) 249 So(j, ShouldEqual, len(t c.expected[i]))
236 } else { 250 } else {
237 So(ok, ShouldBeFalse) 251 So(ok, ShouldBeFalse)
238 } 252 }
239 }) 253 })
240 } 254 }
241 }) 255 })
242 } 256 }
243 }) 257 })
244 } 258 }
245 259
246 func TestIndexEntries(t *testing.T) { 260 func TestIndexEntries(t *testing.T) {
247 t.Parallel() 261 t.Parallel()
248 262
249 Convey("Test indexEntriesWithBuiltins", t, func() { 263 Convey("Test indexEntriesWithBuiltins", t, func() {
250 for _, tc := range rowGenTestCases { 264 for _, tc := range rowGenTestCases {
251 if tc.collections == nil { 265 if tc.collections == nil {
252 Convey(tc.name, nil) // shows up as 'skipped' 266 Convey(tc.name, nil) // shows up as 'skipped'
253 continue 267 continue
254 } 268 }
255 269
256 Convey(tc.name, func() { 270 Convey(tc.name, func() {
257 store := (*memStore)(nil) 271 store := (*memStore)(nil)
258 if tc.withBuiltin { 272 if tc.withBuiltin {
259 store = indexEntriesWithBuiltins(fakeKey , tc.pmap, tc.idxs) 273 store = indexEntriesWithBuiltins(fakeKey , tc.pmap, tc.idxs)
260 } else { 274 } else {
261 » » » » » store = partiallySerialize(tc.pmap).inde xEntries(fakeKey, tc.idxs) 275 » » » » » store = partiallySerialize(fakeKey, tc.p map).indexEntries(fakeKey.Namespace(), tc.idxs)
262 } 276 }
263 for colName, vals := range tc.collections { 277 for colName, vals := range tc.collections {
264 i := 0 278 i := 0
265 store.GetCollection(colName).VisitItemsA scend(nil, true, func(itm *gkvlite.Item) bool { 279 store.GetCollection(colName).VisitItemsA scend(nil, true, func(itm *gkvlite.Item) bool {
266 » » » » » » So(itm.Key, ShouldResemble, vals [i].k) 280 » » » » » » So(itm.Key, ShouldResemble, vals [i])
267 i++ 281 i++
268 return true 282 return true
269 }) 283 })
270 So(i, ShouldEqual, len(vals)) 284 So(i, ShouldEqual, len(vals))
271 } 285 }
272 }) 286 })
273 } 287 }
274 }) 288 })
275 } 289 }
276 290
(...skipping 19 matching lines...) Expand all
296 "wat": {prop(1)}, 310 "wat": {prop(1)},
297 "yerp": {prop(200)}}, 311 "yerp": {prop(200)}},
298 }, 312 },
299 {key("knd", 1), ds.PropertyMap{ 313 {key("knd", 1), ds.PropertyMap{
300 "wat": {prop(10)}, 314 "wat": {prop(10)},
301 "yerp": {prop(202)}}, 315 "yerp": {prop(202)}},
302 }, 316 },
303 }, 317 },
304 expected: map[string][][]byte{ 318 expected: map[string][][]byte{
305 "idx:ns:" + sat(indx("knd", "wat")): { 319 "idx:ns:" + sat(indx("knd", "wat")): {
306 » » » » cat(ds.PTInt, 1, key("knd", 10)), 320 » » » » cat(prop(1), prop(key("knd", 10))),
307 » » » » cat(ds.PTInt, 10, key("knd", 1)), 321 » » » » cat(prop(10), prop(key("knd", 1))),
308 }, 322 },
309 "idx:ns:" + sat(indx("knd", "-wat")): { 323 "idx:ns:" + sat(indx("knd", "-wat")): {
310 » » » » cat(icat(ds.PTInt, 10), key("knd", 1)), 324 » » » » cat(icat(prop(10)), prop(key("knd", 1))),
311 » » » » cat(icat(ds.PTInt, 1), key("knd", 10)), 325 » » » » cat(icat(prop(1)), prop(key("knd", 10))),
312 }, 326 },
313 "idx:ns:" + sat(indx("knd", "yerp")): { 327 "idx:ns:" + sat(indx("knd", "yerp")): {
314 » » » » cat(ds.PTInt, 200, key("knd", 10)), 328 » » » » cat(prop(200), prop(key("knd", 10))),
315 » » » » cat(ds.PTInt, 202, key("knd", 1)), 329 » » » » cat(prop(202), prop(key("knd", 1))),
316 }, 330 },
317 }, 331 },
318 }, 332 },
333
319 { 334 {
320 name: "compound", 335 name: "compound",
321 idxs: []*ds.IndexDefinition{indx("knd", "yerp", "-wat")}, 336 idxs: []*ds.IndexDefinition{indx("knd", "yerp", "-wat")},
322 data: []dumbItem{ 337 data: []dumbItem{
323 {key("knd", 1), ds.PropertyMap{ 338 {key("knd", 1), ds.PropertyMap{
324 "wat": {prop(10)}, 339 "wat": {prop(10)},
325 "yerp": {prop(100)}}, 340 "yerp": {prop(100)}},
326 }, 341 },
327 {key("knd", 10), ds.PropertyMap{ 342 {key("knd", 10), ds.PropertyMap{
328 "wat": {prop(1)}, 343 "wat": {prop(1)},
329 "yerp": {prop(200)}}, 344 "yerp": {prop(200)}},
330 }, 345 },
331 {key("knd", 11), ds.PropertyMap{ 346 {key("knd", 11), ds.PropertyMap{
332 "wat": {prop(20)}, 347 "wat": {prop(20)},
333 "yerp": {prop(200)}}, 348 "yerp": {prop(200)}},
334 }, 349 },
335 {key("knd", 14), ds.PropertyMap{ 350 {key("knd", 14), ds.PropertyMap{
336 "wat": {prop(20)}, 351 "wat": {prop(20)},
337 "yerp": {prop(200)}}, 352 "yerp": {prop(200)}},
338 }, 353 },
339 {key("knd", 1), ds.PropertyMap{ 354 {key("knd", 1), ds.PropertyMap{
340 "wat": {prop(10)}, 355 "wat": {prop(10)},
341 "yerp": {prop(202)}}, 356 "yerp": {prop(202)}},
342 }, 357 },
343 }, 358 },
344 expected: map[string][][]byte{ 359 expected: map[string][][]byte{
345 "idx:ns:" + sat(indx("knd", "yerp", "-wat")): { 360 "idx:ns:" + sat(indx("knd", "yerp", "-wat")): {
346 » » » » cat(ds.PTInt, 200, icat(ds.PTInt, 20), key("knd" , 11)), 361 » » » » cat(prop(200), icat(prop(20)), prop(key("knd", 1 1))),
347 » » » » cat(ds.PTInt, 200, icat(ds.PTInt, 20), key("knd" , 14)), 362 » » » » cat(prop(200), icat(prop(20)), prop(key("knd", 1 4))),
348 » » » » cat(ds.PTInt, 200, icat(ds.PTInt, 1), key("knd", 10)), 363 » » » » cat(prop(200), icat(prop(1)), prop(key("knd", 10 ))),
349 » » » » cat(ds.PTInt, 202, icat(ds.PTInt, 10), key("knd" , 1)), 364 » » » » cat(prop(202), icat(prop(10)), prop(key("knd", 1 ))),
350 }, 365 },
351 }, 366 },
352 }, 367 },
353 } 368 }
354 369
355 func TestUpdateIndicies(t *testing.T) { 370 func TestUpdateIndicies(t *testing.T) {
356 t.Parallel() 371 t.Parallel()
357 372
358 Convey("Test updateIndicies", t, func() { 373 Convey("Test updateIndicies", t, func() {
359 for _, tc := range updateIndiciesTests { 374 for _, tc := range updateIndiciesTests {
(...skipping 21 matching lines...) Expand all
381 So(data[i], ShouldResemble, itm. Key) 396 So(data[i], ShouldResemble, itm. Key)
382 i++ 397 i++
383 return true 398 return true
384 }) 399 })
385 So(i, ShouldEqual, len(data)) 400 So(i, ShouldEqual, len(data))
386 } 401 }
387 }) 402 })
388 } 403 }
389 }) 404 })
390 } 405 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698