mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-10-07 22:57:07 +00:00
Get the first tests running
This commit is contained in:
@@ -1,60 +1,60 @@
|
||||
import assert from 'assert'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import rmrf from 'rimraf'
|
||||
import OrbitDB from '../src/OrbitDB.js'
|
||||
// import assert from 'assert'
|
||||
// import fs from 'fs'
|
||||
// import path from 'path'
|
||||
// import rmrf from 'rimraf'
|
||||
// import OrbitDB from '../src/OrbitDB.js'
|
||||
|
||||
// Include test utilities
|
||||
import {
|
||||
config,
|
||||
startIpfs,
|
||||
stopIpfs,
|
||||
testAPIs,
|
||||
} from 'orbit-db-test-utils'
|
||||
// // Include test utilities
|
||||
// import {
|
||||
// config,
|
||||
// startIpfs,
|
||||
// stopIpfs,
|
||||
// testAPIs,
|
||||
// } from 'orbit-db-test-utils'
|
||||
|
||||
const dbPath = './orbitdb/tests/drop'
|
||||
// const dbPath = './orbitdb/tests/drop'
|
||||
|
||||
Object.keys(testAPIs).forEach(API => {
|
||||
describe(`orbit-db - Drop Database (${API})`, function() {
|
||||
this.timeout(config.timeout)
|
||||
// Object.keys(testAPIs).forEach(API => {
|
||||
// describe(`orbit-db - Drop Database (${API})`, function() {
|
||||
// this.timeout(config.timeout)
|
||||
|
||||
let ipfsd, ipfs, orbitdb, db, address
|
||||
let localDataPath
|
||||
// let ipfsd, ipfs, orbitdb, db, address
|
||||
// let localDataPath
|
||||
|
||||
before(async () => {
|
||||
rmrf.sync(dbPath)
|
||||
ipfsd = await startIpfs(API, config.daemon1)
|
||||
ipfs = ipfsd.api
|
||||
orbitdb = await OrbitDB.createInstance(ipfs, { directory: dbPath })
|
||||
})
|
||||
// before(async () => {
|
||||
// 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()
|
||||
// after(async () => {
|
||||
// if(orbitdb)
|
||||
// await orbitdb.stop()
|
||||
|
||||
if (ipfsd)
|
||||
await stopIpfs(ipfsd)
|
||||
// if (ipfsd)
|
||||
// await stopIpfs(ipfsd)
|
||||
|
||||
rmrf.sync(dbPath)
|
||||
})
|
||||
// rmrf.sync(dbPath)
|
||||
// })
|
||||
|
||||
describe('Drop', function() {
|
||||
before(async () => {
|
||||
db = await orbitdb.create('first', 'feed')
|
||||
localDataPath = path.join(dbPath)
|
||||
assert.equal(fs.existsSync(localDataPath), true)
|
||||
})
|
||||
// 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()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
// 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()
|
||||
// })
|
||||
// })
|
||||
// })
|
||||
// })
|
||||
|
||||
Reference in New Issue
Block a user