-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: assure .hoodie/data folders created when using leveldb (#530)
- Loading branch information
Showing
4 changed files
with
113 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = configurePouchDb | ||
|
||
function configurePouchDb (state, callback) { | ||
state.db.config = new state.PouchDB('hoodie-config').doc('hoodie') | ||
|
||
process.nextTick(function () { | ||
callback() | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
var simple = require('simple-mock') | ||
var test = require('tap').test | ||
|
||
var configurePouchDB = require('../../../lib/config/configure-pouchdb') | ||
|
||
test('pouchdb config', function (t) { | ||
var docApiStub = simple.stub().returnWith('hoodie-config-db') | ||
var PouchDBMock = simple.stub().returnWith({ | ||
doc: docApiStub | ||
}) | ||
var state = { | ||
db: {}, | ||
PouchDB: PouchDBMock | ||
} | ||
|
||
configurePouchDB(state, function (error) { | ||
t.error(error) | ||
|
||
t.is(PouchDBMock.calls.length, 1, 'PouchDB constructor called once') | ||
t.is(PouchDBMock.lastCall.arg, 'hoodie-config', 'PouchDB constructor called with \'hoodie-config\'') | ||
t.is(docApiStub.calls.length, 1, 'PouchDB\'s doc method called once') | ||
t.is(docApiStub.lastCall.arg, 'hoodie', 'doc method called with \'hoodie\'') | ||
|
||
t.is(state.db.config, 'hoodie-config-db', 'config key in state.db set') | ||
|
||
t.end() | ||
}) | ||
}) |