mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-03-30 15:08:28 +00:00
Add a test for dropping a database
This commit is contained in:
parent
5b7fe0b979
commit
7818b5ca79
50
test/drop.test.js
Normal file
50
test/drop.test.js
Normal file
@ -0,0 +1,50 @@
|
||||
'use strict'
|
||||
|
||||
const assert = require('assert')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const rmrf = require('rimraf')
|
||||
const OrbitDB = require('../src/OrbitDB')
|
||||
const config = require('./utils/config')
|
||||
const startIpfs = require('./utils/start-ipfs')
|
||||
|
||||
const dbPath = './orbitdb/tests/drop'
|
||||
const ipfsPath = './orbitdb/tests/drop/ipfs'
|
||||
|
||||
describe('orbit-db - Drop Database', function() {
|
||||
this.timeout(config.timeout)
|
||||
|
||||
let ipfs, orbitdb, db, address
|
||||
let localDataPath
|
||||
|
||||
before(async () => {
|
||||
config.daemon1.repo = ipfsPath
|
||||
rmrf.sync(config.daemon1.repo)
|
||||
rmrf.sync(dbPath)
|
||||
ipfs = await startIpfs(config.daemon1)
|
||||
orbitdb = new OrbitDB(ipfs, dbPath)
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
if(orbitdb)
|
||||
orbitdb.stop()
|
||||
|
||||
if (ipfs)
|
||||
await ipfs.stop()
|
||||
|
||||
rmrf.sync(dbPath)
|
||||
})
|
||||
|
||||
describe('Drop', function() {
|
||||
before(async () => {
|
||||
db = await orbitdb.create('first', 'feed')
|
||||
localDataPath = path.join(dbPath, db.address.root, db.address.path)
|
||||
assert.equal(fs.existsSync(localDataPath), true)
|
||||
})
|
||||
|
||||
it('removes local database files', async () => {
|
||||
await db.drop()
|
||||
assert.equal(fs.existsSync(localDataPath), false)
|
||||
})
|
||||
})
|
||||
})
|
Loading…
x
Reference in New Issue
Block a user