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

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

Issue 1336443003: Implement projection queries correctly. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: Created 5 years, 3 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 "sort" 8 "sort"
9 "testing" 9 "testing"
10 "time" 10 "time"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 So(idxs[4].String(), ShouldEqual, "B:knd /-wat") 81 So(idxs[4].String(), ShouldEqual, "B:knd /-wat")
82 }) 82 })
83 }) 83 })
84 }) 84 })
85 }) 85 })
86 } 86 }
87 87
88 var rgenComplexTime = time.Date( 88 var rgenComplexTime = time.Date(
89 1986, time.October, 26, 1, 20, 00, 00, time.UTC) 89 1986, time.October, 26, 1, 20, 00, 00, time.UTC)
90 var rgenComplexKey = key("kind", "id") 90 var rgenComplexKey = key("kind", "id")
91 var rgenComplexTimeIdx = prop(rgenComplexTime).ForIndex()
iannucci 2015/09/10 03:56:58 this is actually a Property of type PTInt now.
91 92
92 var rowGenTestCases = []struct { 93 var rowGenTestCases = []struct {
93 name string 94 name string
94 pmap ds.PropertyMap 95 pmap ds.PropertyMap
95 withBuiltin bool 96 withBuiltin bool
96 idxs []*ds.IndexDefinition 97 idxs []*ds.IndexDefinition
97 98
98 // These are checked in TestIndexRowGen. nil to skip test case. 99 // These are checked in TestIndexRowGen. nil to skip test case.
99 expected []serializedPvals 100 expected []serializedPvals
100 101
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 }, 157 },
157 }, 158 },
158 }, 159 },
159 160
160 { 161 {
161 name: "complex", 162 name: "complex",
162 pmap: ds.PropertyMap{ 163 pmap: ds.PropertyMap{
163 "yerp": {prop("hat"), prop(73.9)}, 164 "yerp": {prop("hat"), prop(73.9)},
164 "wat": { 165 "wat": {
165 prop(rgenComplexTime), 166 prop(rgenComplexTime),
166 » » » » prop(ds.ByteString("value")), 167 » » » » prop([]byte("value")),
167 prop(rgenComplexKey)}, 168 prop(rgenComplexKey)},
168 "spaz": {prop(nil), prop(false), prop(true)}, 169 "spaz": {prop(nil), prop(false), prop(true)},
169 }, 170 },
170 idxs: []*ds.IndexDefinition{ 171 idxs: []*ds.IndexDefinition{
171 indx("knd", "-wat", "nerd", "spaz"), // doesn't match, s o empty 172 indx("knd", "-wat", "nerd", "spaz"), // doesn't match, s o empty
172 indx("knd", "yerp", "-wat", "spaz"), 173 indx("knd", "yerp", "-wat", "spaz"),
173 }, 174 },
174 expected: []serializedPvals{ 175 expected: []serializedPvals{
175 {}, // C:knd/-wat/nerd/spaz, no match 176 {}, // C:knd/-wat/nerd/spaz, no match
176 { // C:knd/yerp/-wat/spaz 177 { // C:knd/yerp/-wat/spaz
177 // thank goodness the binary serialization only happens 1/val in the 178 // thank goodness the binary serialization only happens 1/val in the
178 // real code :). 179 // real code :).
179 cat(prop("hat"), icat(prop(rgenComplexKey)), pro p(nil), prop(fakeKey)), 180 cat(prop("hat"), icat(prop(rgenComplexKey)), pro p(nil), prop(fakeKey)),
180 cat(prop("hat"), icat(prop(rgenComplexKey)), pro p(false), prop(fakeKey)), 181 cat(prop("hat"), icat(prop(rgenComplexKey)), pro p(false), prop(fakeKey)),
181 cat(prop("hat"), icat(prop(rgenComplexKey)), pro p(true), prop(fakeKey)), 182 cat(prop("hat"), icat(prop(rgenComplexKey)), pro p(true), prop(fakeKey)),
182 » » » » cat(prop("hat"), icat(prop(ds.ByteString("value" ))), prop(nil), prop(fakeKey)), 183 » » » » cat(prop("hat"), icat(prop("value")), prop(nil), prop(fakeKey)),
183 » » » » cat(prop("hat"), icat(prop(ds.ByteString("value" ))), prop(false), prop(fakeKey)), 184 » » » » cat(prop("hat"), icat(prop("value")), prop(false ), prop(fakeKey)),
184 » » » » cat(prop("hat"), icat(prop(ds.ByteString("value" ))), prop(true), prop(fakeKey)), 185 » » » » cat(prop("hat"), icat(prop("value")), prop(true) , prop(fakeKey)),
iannucci 2015/09/10 03:56:58 you can see that []byte and string are no longer d
185 » » » » cat(prop("hat"), icat(prop(rgenComplexTime)), pr op(nil), prop(fakeKey)), 186 » » » » cat(prop("hat"), icat(rgenComplexTimeIdx), prop( nil), prop(fakeKey)),
186 » » » » cat(prop("hat"), icat(prop(rgenComplexTime)), pr op(false), prop(fakeKey)), 187 » » » » cat(prop("hat"), icat(rgenComplexTimeIdx), prop( false), prop(fakeKey)),
187 » » » » cat(prop("hat"), icat(prop(rgenComplexTime)), pr op(true), prop(fakeKey)), 188 » » » » cat(prop("hat"), icat(rgenComplexTimeIdx), prop( true), prop(fakeKey)),
188 189
189 cat(prop(73.9), icat(prop(rgenComplexKey)), prop (nil), prop(fakeKey)), 190 cat(prop(73.9), icat(prop(rgenComplexKey)), prop (nil), prop(fakeKey)),
190 cat(prop(73.9), icat(prop(rgenComplexKey)), prop (false), prop(fakeKey)), 191 cat(prop(73.9), icat(prop(rgenComplexKey)), prop (false), prop(fakeKey)),
191 cat(prop(73.9), icat(prop(rgenComplexKey)), prop (true), prop(fakeKey)), 192 cat(prop(73.9), icat(prop(rgenComplexKey)), prop (true), prop(fakeKey)),
192 » » » » cat(prop(73.9), icat(prop(ds.ByteString("value") )), prop(nil), prop(fakeKey)), 193 » » » » cat(prop(73.9), icat(prop("value")), prop(nil), prop(fakeKey)),
193 » » » » cat(prop(73.9), icat(prop(ds.ByteString("value") )), prop(false), prop(fakeKey)), 194 » » » » cat(prop(73.9), icat(prop("value")), prop(false) , prop(fakeKey)),
194 » » » » cat(prop(73.9), icat(prop(ds.ByteString("value") )), prop(true), prop(fakeKey)), 195 » » » » cat(prop(73.9), icat(prop("value")), prop(true), prop(fakeKey)),
195 » » » » cat(prop(73.9), icat(prop(rgenComplexTime)), pro p(nil), prop(fakeKey)), 196 » » » » cat(prop(73.9), icat(rgenComplexTimeIdx), prop(n il), prop(fakeKey)),
196 » » » » cat(prop(73.9), icat(prop(rgenComplexTime)), pro p(false), prop(fakeKey)), 197 » » » » cat(prop(73.9), icat(rgenComplexTimeIdx), prop(f alse), prop(fakeKey)),
197 » » » » cat(prop(73.9), icat(prop(rgenComplexTime)), pro p(true), prop(fakeKey)), 198 » » » » cat(prop(73.9), icat(rgenComplexTimeIdx), prop(t rue), prop(fakeKey)),
198 }, 199 },
199 }, 200 },
200 }, 201 },
201 202
202 { 203 {
203 name: "ancestor", 204 name: "ancestor",
204 pmap: ds.PropertyMap{ 205 pmap: ds.PropertyMap{
205 "wat": {prop("sup")}, 206 "wat": {prop("sup")},
206 }, 207 },
207 idxs: []*ds.IndexDefinition{ 208 idxs: []*ds.IndexDefinition{
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 So(data[i], ShouldResemble, itm. Key) 404 So(data[i], ShouldResemble, itm. Key)
404 i++ 405 i++
405 return true 406 return true
406 }) 407 })
407 So(i, ShouldEqual, len(data)) 408 So(i, ShouldEqual, len(data))
408 } 409 }
409 }) 410 })
410 } 411 }
411 }) 412 })
412 } 413 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698