Test directory existence in persisted key-value store

This commit is contained in:
haad 2023-03-09 08:39:21 +02:00
parent ec3f5cbfa0
commit 5a72a16e58

View File

@ -1,4 +1,6 @@
import { deepStrictEqual, strictEqual } from 'assert' import { deepStrictEqual, strictEqual } from 'assert'
import path from 'path'
import fs from 'fs'
import rmrf from 'rimraf' import rmrf from 'rimraf'
import { copy } from 'fs-extra' import { copy } from 'fs-extra'
import * as IPFS from 'ipfs' import * as IPFS from 'ipfs'
@ -59,6 +61,12 @@ describe('KeyValuePersisted Database', function () {
strictEqual(db.type, 'keyvalue') strictEqual(db.type, 'keyvalue')
}) })
it('creates a directory for the persisted index', async () => {
const expectedPath = path.join('./orbitdb', `./${db.address}`, '/_index')
const directoryExists = fs.existsSync(expectedPath)
strictEqual(directoryExists, true)
})
it('returns 0 items when it\'s a fresh database', async () => { it('returns 0 items when it\'s a fresh database', async () => {
const all = [] const all = []
for await (const item of db.iterator()) { for await (const item of db.iterator()) {