@@ -185,6 +185,16 @@ func generateTestRandomChunk() chunk.Chunk {
185
185
return chunk .NewChunk (key , data )
186
186
}
187
187
188
+ // generateTestRandomChunks generates a slice of random
189
+ // Chunks by using generateTestRandomChunk function.
190
+ func generateTestRandomChunks (count int ) []chunk.Chunk {
191
+ chunks := make ([]chunk.Chunk , count )
192
+ for i := 0 ; i < count ; i ++ {
193
+ chunks [i ] = generateTestRandomChunk ()
194
+ }
195
+ return chunks
196
+ }
197
+
188
198
// TestGenerateTestRandomChunk validates that
189
199
// generateTestRandomChunk returns random data by comparing
190
200
// two generated chunks.
@@ -219,6 +229,8 @@ func TestGenerateTestRandomChunk(t *testing.T) {
219
229
// chunk values are in the retrieval indexes.
220
230
func newRetrieveIndexesTest (db * DB , chunk chunk.Chunk , storeTimestamp , accessTimestamp int64 ) func (t * testing.T ) {
221
231
return func (t * testing.T ) {
232
+ t .Helper ()
233
+
222
234
item , err := db .retrievalDataIndex .Get (addressToItem (chunk .Address ()))
223
235
if err != nil {
224
236
t .Fatal (err )
@@ -238,6 +250,8 @@ func newRetrieveIndexesTest(db *DB, chunk chunk.Chunk, storeTimestamp, accessTim
238
250
// chunk values are in the retrieval indexes when access time must be stored.
239
251
func newRetrieveIndexesTestWithAccess (db * DB , ch chunk.Chunk , storeTimestamp , accessTimestamp int64 ) func (t * testing.T ) {
240
252
return func (t * testing.T ) {
253
+ t .Helper ()
254
+
241
255
item , err := db .retrievalDataIndex .Get (addressToItem (ch .Address ()))
242
256
if err != nil {
243
257
t .Fatal (err )
@@ -258,6 +272,8 @@ func newRetrieveIndexesTestWithAccess(db *DB, ch chunk.Chunk, storeTimestamp, ac
258
272
// chunk values are in the pull index.
259
273
func newPullIndexTest (db * DB , ch chunk.Chunk , binID uint64 , wantError error ) func (t * testing.T ) {
260
274
return func (t * testing.T ) {
275
+ t .Helper ()
276
+
261
277
item , err := db .pullIndex .Get (shed.Item {
262
278
Address : ch .Address (),
263
279
BinID : binID ,
@@ -275,6 +291,8 @@ func newPullIndexTest(db *DB, ch chunk.Chunk, binID uint64, wantError error) fun
275
291
// chunk values are in the push index.
276
292
func newPushIndexTest (db * DB , ch chunk.Chunk , storeTimestamp int64 , wantError error ) func (t * testing.T ) {
277
293
return func (t * testing.T ) {
294
+ t .Helper ()
295
+
278
296
item , err := db .pushIndex .Get (shed.Item {
279
297
Address : ch .Address (),
280
298
StoreTimestamp : storeTimestamp ,
@@ -292,6 +310,8 @@ func newPushIndexTest(db *DB, ch chunk.Chunk, storeTimestamp int64, wantError er
292
310
// chunk values are in the push index.
293
311
func newGCIndexTest (db * DB , chunk chunk.Chunk , storeTimestamp , accessTimestamp int64 , binID uint64 ) func (t * testing.T ) {
294
312
return func (t * testing.T ) {
313
+ t .Helper ()
314
+
295
315
item , err := db .gcIndex .Get (shed.Item {
296
316
Address : chunk .Address (),
297
317
BinID : binID ,
@@ -308,6 +328,8 @@ func newGCIndexTest(db *DB, chunk chunk.Chunk, storeTimestamp, accessTimestamp i
308
328
// an index contains expected number of key/value pairs.
309
329
func newItemsCountTest (i shed.Index , want int ) func (t * testing.T ) {
310
330
return func (t * testing.T ) {
331
+ t .Helper ()
332
+
311
333
var c int
312
334
err := i .Iterate (func (item shed.Item ) (stop bool , err error ) {
313
335
c ++
@@ -326,6 +348,8 @@ func newItemsCountTest(i shed.Index, want int) func(t *testing.T) {
326
348
// value is the same as the number of items in DB.gcIndex.
327
349
func newIndexGCSizeTest (db * DB ) func (t * testing.T ) {
328
350
return func (t * testing.T ) {
351
+ t .Helper ()
352
+
329
353
var want uint64
330
354
err := db .gcIndex .Iterate (func (item shed.Item ) (stop bool , err error ) {
331
355
want ++
@@ -354,6 +378,8 @@ type testIndexChunk struct {
354
378
// testItemsOrder tests the order of chunks in the index. If sortFunc is not nil,
355
379
// chunks will be sorted with it before validation.
356
380
func testItemsOrder (t * testing.T , i shed.Index , chunks []testIndexChunk , sortFunc func (i , j int ) (less bool )) {
381
+ t .Helper ()
382
+
357
383
newItemsCountTest (i , len (chunks ))(t )
358
384
359
385
if sortFunc != nil {
0 commit comments