Skip to content

Commit 60e6c3f

Browse files
authored
fix: rename test from blocks to getMany (#190)
For consistency with the other tests that are named after the method they test.
1 parent 1d1079c commit 60e6c3f

File tree

1 file changed

+37
-37
lines changed
  • packages/interface-blockstore-tests/src

1 file changed

+37
-37
lines changed

packages/interface-blockstore-tests/src/index.ts

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,43 @@ export function interfaceBlockstoreTests <B extends Blockstore = Blockstore> (te
177177
})
178178
})
179179

180+
describe('getAll', () => {
181+
let store: B
182+
183+
beforeEach(async () => {
184+
store = await createStore()
185+
})
186+
187+
afterEach(async () => {
188+
await cleanup(store)
189+
})
190+
191+
it('returns all blocks', async () => {
192+
const data = await getKeyValuePairs(100)
193+
194+
await drain(store.putMany(data))
195+
196+
const allBlocks = await all(store.getAll())
197+
198+
expect(allBlocks).of.have.lengthOf(data.length)
199+
200+
// order is not preserved
201+
for (const { cid, block } of data) {
202+
const retrievedPair = allBlocks.find(pair => {
203+
return base32.encode(cid.multihash.bytes) === base32.encode(pair.cid.multihash.bytes)
204+
})
205+
206+
expect(retrievedPair).to.be.ok()
207+
208+
if (retrievedPair == null) {
209+
throw new Error('Could not find cid/block pair')
210+
}
211+
212+
expect(retrievedPair.block).to.equalBytes(block)
213+
}
214+
})
215+
})
216+
180217
describe('delete', () => {
181218
let store: B
182219

@@ -247,41 +284,4 @@ export function interfaceBlockstoreTests <B extends Blockstore = Blockstore> (te
247284
res1.forEach(res => expect(res).to.be.eql(false))
248285
})
249286
})
250-
251-
describe('blocks', () => {
252-
let store: B
253-
254-
beforeEach(async () => {
255-
store = await createStore()
256-
})
257-
258-
afterEach(async () => {
259-
await cleanup(store)
260-
})
261-
262-
it('returns all blocks', async () => {
263-
const data = await getKeyValuePairs(100)
264-
265-
await drain(store.putMany(data))
266-
267-
const allBlocks = await all(store.getAll())
268-
269-
expect(allBlocks).of.have.lengthOf(data.length)
270-
271-
// order is not preserved
272-
for (const { cid, block } of data) {
273-
const retrievedPair = allBlocks.find(pair => {
274-
return base32.encode(cid.multihash.bytes) === base32.encode(pair.cid.multihash.bytes)
275-
})
276-
277-
expect(retrievedPair).to.be.ok()
278-
279-
if (retrievedPair == null) {
280-
throw new Error('Could not find cid/block pair')
281-
}
282-
283-
expect(retrievedPair.block).to.equalBytes(block)
284-
}
285-
})
286-
})
287287
}

0 commit comments

Comments
 (0)