Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cli/parse-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ function parseOptions (options) {
config.inMemory = true
log.info('config', 'Storing all data in memory only')
} else {
if (!options.dbAdapter || typeof options.dbAdapter !== 'string') {
throw new Error('dbAdapter must be specified as a string when not using dbUrl or inMemory mode')
}
PouchDB.plugin(require(options.dbAdapter))
dbOptions.prefix = path.join(config.paths.data, 'data') + path.sep
log.info('config', 'Storing all data in ' + dbOptions.prefix + ' using ' + options.dbAdapter)
Expand Down
16 changes: 14 additions & 2 deletions test/unit/cli/parse-options-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ function getDefaultsMock () {
}

var logMock = {
info: function () {},
warn: function () {}
info: function () { },
warn: function () { }
}

var parseOptions = proxyquire('../../../cli/parse-options', {
Expand Down Expand Up @@ -315,5 +315,17 @@ test('parse options', function (group) {
t.end()
})

group.test('missing dbAdapter throws error', function (t) {
t.throws(parseOptions.bind(null, {
public: 'public',
data: 'data'
// dbAdapter is intentionally missing
// dbUrl is not provided
// inMemory is not set
}), 'throws error when dbAdapter is missing')

t.end()
})

group.end()
})