mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-03-30 15:08:28 +00:00

package-lock pointing to branch more cache management stuff WIP Passing tests Removing static linking fixing tests and linting fixing package.json removing last debugger removing last debugger Adding keystore and cache getters PR comments Removing extraneous cache management Package files Closing caches using dbAddress as this.caches key new tests for store management Working but with slightly different semantics Rebuild package-lock Dependency updates removeHandler restoring db.close in replication status test package.json files move handler to orbitdb.caches Test updates Cache management cleanup use store.options.directory requestCache in onLoad and onDrop add status test Adding db to this.stores in onLoad and onDrop Working RC5 before rebase Updating package-lock restoring original replicaiton status test package files removing keystore getter more keystore cleanup typo
66 lines
1.7 KiB
JavaScript
66 lines
1.7 KiB
JavaScript
'use strict'
|
|
|
|
const assert = require('assert')
|
|
const fs = require('fs')
|
|
const path = require('path')
|
|
const rmrf = require('rimraf')
|
|
const OrbitDB = require('../src/OrbitDB')
|
|
|
|
// Include test utilities
|
|
const {
|
|
config,
|
|
startIpfs,
|
|
stopIpfs,
|
|
testAPIs,
|
|
} = require('./utils')
|
|
|
|
const dbPath = './orbitdb/tests/drop'
|
|
const ipfsPath = './orbitdb/tests/drop/ipfs'
|
|
|
|
Object.keys(testAPIs).forEach(API => {
|
|
describe(`orbit-db - Drop Database (${API})`, function() {
|
|
this.timeout(config.timeout)
|
|
|
|
let ipfsd, ipfs, orbitdb, db, address
|
|
let localDataPath
|
|
|
|
before(async () => {
|
|
config.daemon1.repo = ipfsPath
|
|
rmrf.sync(config.daemon1.repo)
|
|
rmrf.sync(dbPath)
|
|
ipfsd = await startIpfs(API, config.daemon1)
|
|
ipfs = ipfsd.api
|
|
orbitdb = await OrbitDB.createInstance(ipfs, { directory: dbPath })
|
|
})
|
|
|
|
after(async () => {
|
|
if(orbitdb)
|
|
await orbitdb.stop()
|
|
|
|
if (ipfsd)
|
|
await stopIpfs(ipfsd)
|
|
|
|
rmrf.sync(dbPath)
|
|
})
|
|
|
|
describe('Drop', function() {
|
|
before(async () => {
|
|
db = await orbitdb.create('first', 'feed')
|
|
localDataPath = path.join(dbPath)
|
|
assert.equal(fs.existsSync(localDataPath), true)
|
|
})
|
|
|
|
it('removes local database cache', async () => {
|
|
await db.drop()
|
|
await db._cache.open()
|
|
assert.equal(await db._cache.get(db.localHeadsPath), undefined)
|
|
assert.equal(await db._cache.get(db.remoteHeadsPath), undefined)
|
|
assert.equal(await db._cache.get(db.snapshotPath), undefined)
|
|
assert.equal(await db._cache.get(db.queuePath), undefined)
|
|
assert.equal(await db._cache.get(db.manifestPath), undefined)
|
|
await db._cache.close()
|
|
})
|
|
})
|
|
})
|
|
})
|