fix(ipfs): Deleting /blocks dir if it prevents app from starting

This commit is contained in:
Chris Troutner
2021-12-06 12:46:22 -08:00
parent 74c6bc5737
commit 1e513cc133
2 changed files with 52 additions and 1 deletions
+21
View File
@@ -60,4 +60,25 @@ describe('#IPFS-adapter', () => {
assert.equal(result, true)
})
})
describe('#rmBlocksDir', () => {
it('should delete the /blocks directory', () => {
const result = uut.rmBlocksDir()
assert.equal(result, true)
})
it('should catch and throw an error', () => {
try {
// Force an error
sandbox.stub(uut.fs, 'rmdirSync').throws(new Error('test error'))
uut.rmBlocksDir()
assert.fail('Unexpected code path')
} catch (err) {
assert.equal(err.message, 'test error')
}
})
})
})