func TestPinIndexes(t *testing.T) {
	ctx := context.Background()
	t.Cleanup(setWithinRadiusFunc(func(_ *DB, _ shed.Item) bool { return false }))

	db := newTestDB(t, &Options{
		Capacity: 150,
	})

	ch := generateTestRandomChunk()
	// call unreserve on the batch with radius 0 so that
	// localstore is aware of the batch and the chunk can
	// be inserted into the database
	unreserveChunkBatch(t, db, 0, ch)

	addr := ch.Address()
	_, err := db.Put(ctx, storage.ModePutUpload, ch)
	if err != nil {
		t.Fatal(err)
	}
	runCountsTest(t, "putUpload", db, 1, 0, 1, 1, 0, 0)

	err = db.Set(ctx, storage.ModeSetSync, addr)
	if err != nil {
		t.Fatal(err)
	}
	runCountsTest(t, "setSync", db, 1, 1, 0, 1, 0, 1)

	err = db.Set(ctx, storage.ModeSetPin, addr)
	if err != nil {
		t.Fatal(err)
	}
	runCountsTest(t, "setPin", db, 1, 1, 0, 1, 1, 0)

	err = db.Set(ctx, storage.ModeSetPin, addr)
	if err != nil {
		t.Fatal(err)
	}
	runCountsTest(t, "setPin 2", db, 1, 1, 0, 1, 1, 0)

	err = db.Set(ctx, storage.ModeSetUnpin, addr)
	if err != nil {
		t.Fatal(err)
	}
	runCountsTest(t, "setUnPin", db, 1, 1, 0, 1, 1, 0)

	err = db.Set(ctx, storage.ModeSetUnpin, addr)
	if err != nil {
		t.Fatal(err)
	}
	runCountsTest(t, "setUnPin 2", db, 1, 1, 0, 1, 0, 1)

}
// Pin a file, upload chunks to go past the gc limit to trigger GC,
// check if the pinned files are still around and removed from gcIndex
Pin a file, upload chunks to go past the gc limit to trigger GC,
check if the pinned files are still around and removed from gcIndex
// Pin a file upload chunks to go past the gc limit to trigger GC // check if the pinned files are still around and removed from gcIndex
func TestPinIndexes(t *testing.T) {
	ctx := context.Background()
	t.Cleanup(setWithinRadiusFunc(func(_ *DB, _ shed.Item) bool { return false }))
	db := newTestDB(t, &Options{
		Capacity: 150,
	})
	ch := generateTestRandomChunk()
	unreserveChunkBatch(t, db, 0, ch)
	addr := ch.Address()
	_, err := db.Put(ctx, storage.ModePutUpload, ch)
	if err != nil {
		t.Fatal(err)
	}
	runCountsTest(t, "putUpload", db, 1, 0, 1, 1, 0, 0)
	err = db.Set(ctx, storage.ModeSetSync, addr)
	if err != nil {
		t.Fatal(err)
	}
	runCountsTest(t, "setSync", db, 1, 1, 0, 1, 0, 1)
	err = db.Set(ctx, storage.ModeSetPin, addr)
	if err != nil {
		t.Fatal(err)
	}
	runCountsTest(t, "setPin", db, 1, 1, 0, 1, 1, 0)
	err = db.Set(ctx, storage.ModeSetPin, addr)
	if err != nil {
		t.Fatal(err)
	}
	runCountsTest(t, "setPin 2", db, 1, 1, 0, 1, 1, 0)
	err = db.Set(ctx, storage.ModeSetUnpin, addr)
	if err != nil {
		t.Fatal(err)
	}
	runCountsTest(t, "setUnPin", db, 1, 1, 0, 1, 1, 0)
	err = db.Set(ctx, storage.ModeSetUnpin, addr)
	if err != nil {
		t.Fatal(err)
	}
	runCountsTest(t, "setUnPin 2", db, 1, 1, 0, 1, 0, 1)
}
func TestPinIndexes ( t * testing . T ) { ctx := context . Background ( ) t . Cleanup ( setWithinRadiusFunc ( func ( _ * DB , _ shed . Item ) bool { return false } ) ) db := newTestDB ( t , & Options { Capacity : 150 , } ) ch := generateTestRandomChunk ( ) unreserveChunkBatch ( t , db , 0 , ch ) addr := ch . Address ( ) _ , err := db . Put ( ctx , storage . ModePutUpload , ch ) if err != nil { t . Fatal ( err ) } runCountsTest ( t , " " , db , 1 , 0 , 1 , 1 , 0 , 0 ) err = db . Set ( ctx , storage . ModeSetSync , addr ) if err != nil { t . Fatal ( err ) } runCountsTest ( t , " " , db , 1 , 1 , 0 , 1 , 0 , 1 ) err = db . Set ( ctx , storage . ModeSetPin , addr ) if err != nil { t . Fatal ( err ) } runCountsTest ( t , " " , db , 1 , 1 , 0 , 1 , 1 , 0 ) err = db . Set ( ctx , storage . ModeSetPin , addr ) if err != nil { t . Fatal ( err ) } runCountsTest ( t , " " , db , 1 , 1 , 0 , 1 , 1 , 0 ) err = db . Set ( ctx , storage . ModeSetUnpin , addr ) if err != nil { t . Fatal ( err ) } runCountsTest ( t , " " , db , 1 , 1 , 0 , 1 , 1 , 0 ) err = db . Set ( ctx , storage . ModeSetUnpin , addr ) if err != nil { t . Fatal ( err ) } runCountsTest ( t , " " , db , 1 , 1 , 0 , 1 , 0 , 1 ) }
Pin a file, upload chunks to go past the gc limit to trigger GC,
check if the pinned files are still around and removed from gcIndex
Pin a file upload chunks to go past the gc limit to trigger GC check if the pinned files are still around and removed from gcIndex
// call unreserve on the batch with radius 0 so that // localstore is aware of the batch and the chunk can // be inserted into the database