@@ -11,6 +11,7 @@ import (
11
11
)
12
12
13
13
var exampleBlock = blocks .NewBlock ([]byte ("foo" ))
14
+ var exampleBlock2 = blocks .NewBlock ([]byte ("bar" ))
14
15
15
16
func testArcCached (ctx context.Context , bs Blockstore ) (* arccache , error ) {
16
17
if ctx == nil {
@@ -246,16 +247,34 @@ func TestDifferentKeyObjectsWork(t *testing.T) {
246
247
}
247
248
248
249
func TestPutManyCaches (t * testing.T ) {
249
- arc , _ , cd := createStores (t )
250
- arc .PutMany ([]blocks.Block {exampleBlock })
250
+ t .Run ("happy path PutMany" , func (t * testing.T ) {
251
+ arc , _ , cd := createStores (t )
252
+ arc .PutMany ([]blocks.Block {exampleBlock })
253
+
254
+ trap ("has hit datastore" , cd , t )
255
+ arc .Has (exampleBlock .Cid ())
256
+ arc .GetSize (exampleBlock .Cid ())
257
+ untrap (cd )
258
+ arc .DeleteBlock (exampleBlock .Cid ())
259
+
260
+ arc .Put (exampleBlock )
261
+ trap ("PunMany has hit datastore" , cd , t )
262
+ arc .PutMany ([]blocks.Block {exampleBlock })
263
+ })
251
264
252
- trap ("has hit datastore" , cd , t )
253
- arc .Has (exampleBlock .Cid ())
254
- arc .GetSize (exampleBlock .Cid ())
255
- untrap (cd )
256
- arc .DeleteBlock (exampleBlock .Cid ())
265
+ t .Run ("PutMany with duplicates" , func (t * testing.T ) {
266
+ arc , _ , cd := createStores (t )
267
+ arc .PutMany ([]blocks.Block {exampleBlock , exampleBlock2 , exampleBlock })
268
+
269
+ trap ("has hit datastore" , cd , t )
270
+ arc .Has (exampleBlock .Cid ())
271
+ arc .GetSize (exampleBlock .Cid ())
272
+ untrap (cd )
273
+ arc .DeleteBlock (exampleBlock .Cid ())
274
+
275
+ arc .Put (exampleBlock )
276
+ trap ("PunMany has hit datastore" , cd , t )
277
+ arc .PutMany ([]blocks.Block {exampleBlock })
278
+ })
257
279
258
- arc .Put (exampleBlock )
259
- trap ("PunMany has hit datastore" , cd , t )
260
- arc .PutMany ([]blocks.Block {exampleBlock })
261
280
}
0 commit comments