Skip to content

Commit

Permalink
fix: rename test from blocks to getMany (#190)
Browse files Browse the repository at this point in the history
For consistency with the other tests that are named after the method they test.
  • Loading branch information
achingbrain authored Mar 14, 2023
1 parent 1d1079c commit 60e6c3f
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions packages/interface-blockstore-tests/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,43 @@ export function interfaceBlockstoreTests <B extends Blockstore = Blockstore> (te
})
})

describe('getAll', () => {
let store: B

beforeEach(async () => {
store = await createStore()
})

afterEach(async () => {
await cleanup(store)
})

it('returns all blocks', async () => {
const data = await getKeyValuePairs(100)

await drain(store.putMany(data))

const allBlocks = await all(store.getAll())

expect(allBlocks).of.have.lengthOf(data.length)

// order is not preserved
for (const { cid, block } of data) {
const retrievedPair = allBlocks.find(pair => {
return base32.encode(cid.multihash.bytes) === base32.encode(pair.cid.multihash.bytes)
})

expect(retrievedPair).to.be.ok()

if (retrievedPair == null) {
throw new Error('Could not find cid/block pair')
}

expect(retrievedPair.block).to.equalBytes(block)
}
})
})

describe('delete', () => {
let store: B

Expand Down Expand Up @@ -247,41 +284,4 @@ export function interfaceBlockstoreTests <B extends Blockstore = Blockstore> (te
res1.forEach(res => expect(res).to.be.eql(false))
})
})

describe('blocks', () => {
let store: B

beforeEach(async () => {
store = await createStore()
})

afterEach(async () => {
await cleanup(store)
})

it('returns all blocks', async () => {
const data = await getKeyValuePairs(100)

await drain(store.putMany(data))

const allBlocks = await all(store.getAll())

expect(allBlocks).of.have.lengthOf(data.length)

// order is not preserved
for (const { cid, block } of data) {
const retrievedPair = allBlocks.find(pair => {
return base32.encode(cid.multihash.bytes) === base32.encode(pair.cid.multihash.bytes)
})

expect(retrievedPair).to.be.ok()

if (retrievedPair == null) {
throw new Error('Could not find cid/block pair')
}

expect(retrievedPair.block).to.equalBytes(block)
}
})
})
}

0 comments on commit 60e6c3f

Please sign in to comment.