| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 Convey("default indexes", t, func() { | 197 Convey("default indexes", t, func() { |
| 198 Convey("nil collated", func() { | 198 Convey("nil collated", func() { |
| 199 Convey("defaultIndexes (nil)", func() { | 199 Convey("defaultIndexes (nil)", func() { |
| 200 idxs := defaultIndexes("knd", ds.PropertyMap(nil
)) | 200 idxs := defaultIndexes("knd", ds.PropertyMap(nil
)) |
| 201 So(len(idxs), ShouldEqual, 1) | 201 So(len(idxs), ShouldEqual, 1) |
| 202 So(idxs[0].String(), ShouldEqual, "B:knd") | 202 So(idxs[0].String(), ShouldEqual, "B:knd") |
| 203 }) | 203 }) |
| 204 | 204 |
| 205 Convey("indexEntries", func() { | 205 Convey("indexEntries", func() { |
| 206 sip := serialize.PropertyMapPartially(fakeKey, n
il) | 206 sip := serialize.PropertyMapPartially(fakeKey, n
il) |
| 207 » » » » s := indexEntries(sip, "ns", defaultIndexes("knd
", ds.PropertyMap(nil))) | 207 » » » » s := indexEntries(fakeKey, sip, defaultIndexes("
knd", ds.PropertyMap(nil))) |
| 208 numItems, _ := s.GetCollection("idx").GetTotals(
) | 208 numItems, _ := s.GetCollection("idx").GetTotals(
) |
| 209 So(numItems, ShouldEqual, 1) | 209 So(numItems, ShouldEqual, 1) |
| 210 itm := s.GetCollection("idx").MinItem(false) | 210 itm := s.GetCollection("idx").MinItem(false) |
| 211 So(itm.Key, ShouldResemble, cat(indx("knd").Prep
ForIdxTable())) | 211 So(itm.Key, ShouldResemble, cat(indx("knd").Prep
ForIdxTable())) |
| 212 numItems, _ = s.GetCollection("idx:ns:" + string
(itm.Key)).GetTotals() | 212 numItems, _ = s.GetCollection("idx:ns:" + string
(itm.Key)).GetTotals() |
| 213 So(numItems, ShouldEqual, 1) | 213 So(numItems, ShouldEqual, 1) |
| 214 }) | 214 }) |
| 215 | 215 |
| 216 Convey("defaultIndexes", func() { | 216 Convey("defaultIndexes", func() { |
| 217 pm := ds.PropertyMap{ | 217 pm := ds.PropertyMap{ |
| (...skipping 23 matching lines...) Expand all Loading... |
| 241 Convey(tc.name, nil) // shows up as 'skipped' | 241 Convey(tc.name, nil) // shows up as 'skipped' |
| 242 continue | 242 continue |
| 243 } | 243 } |
| 244 | 244 |
| 245 Convey(tc.name, func() { | 245 Convey(tc.name, func() { |
| 246 store := (memStore)(nil) | 246 store := (memStore)(nil) |
| 247 if tc.withBuiltin { | 247 if tc.withBuiltin { |
| 248 store = indexEntriesWithBuiltins(fakeKey
, tc.pmap, tc.idxs) | 248 store = indexEntriesWithBuiltins(fakeKey
, tc.pmap, tc.idxs) |
| 249 } else { | 249 } else { |
| 250 sip := serialize.PropertyMapPartially(fa
keKey, tc.pmap) | 250 sip := serialize.PropertyMapPartially(fa
keKey, tc.pmap) |
| 251 » » » » » store = indexEntries(sip, fakeKey.Namesp
ace(), tc.idxs) | 251 » » » » » store = indexEntries(fakeKey, sip, tc.id
xs) |
| 252 } | 252 } |
| 253 for colName, vals := range tc.collections { | 253 for colName, vals := range tc.collections { |
| 254 i := 0 | 254 i := 0 |
| 255 coll := store.Snapshot().GetCollection(c
olName) | 255 coll := store.Snapshot().GetCollection(c
olName) |
| 256 numItems, _ := coll.GetTotals() | 256 numItems, _ := coll.GetTotals() |
| 257 So(numItems, ShouldEqual, len(tc.collect
ions[colName])) | 257 So(numItems, ShouldEqual, len(tc.collect
ions[colName])) |
| 258 coll.VisitItemsAscend(nil, true, func(it
m *gkvlite.Item) bool { | 258 coll.VisitItemsAscend(nil, true, func(it
m *gkvlite.Item) bool { |
| 259 So(itm.Key, ShouldResemble, vals
[i]) | 259 So(itm.Key, ShouldResemble, vals
[i]) |
| 260 i++ | 260 i++ |
| 261 return true | 261 return true |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 So(data[i], ShouldResemble, itm.
Key) | 376 So(data[i], ShouldResemble, itm.
Key) |
| 377 i++ | 377 i++ |
| 378 return true | 378 return true |
| 379 }) | 379 }) |
| 380 So(i, ShouldEqual, len(data)) | 380 So(i, ShouldEqual, len(data)) |
| 381 } | 381 } |
| 382 }) | 382 }) |
| 383 } | 383 } |
| 384 }) | 384 }) |
| 385 } | 385 } |
| OLD | NEW |