-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Labels
Description
Please advise me if I'm doing something wrong. My goal is to use 'allDbs' in my unit tests, which use the memdown adaptor. But I cannot determine how to get this to work. I am trying to the PouchDB.defaults() method to set the adaptor, which appears to work for most normal functions, but this plugin appears to ignore it.
Here is a minimal reproduction case. Save this file as 'test.js' in an empty directory:
var PouchDB = require('pouchdb');
require('pouchdb-all-dbs')(PouchDB);
var MemDB = PouchDB.defaults({
'db': require('memdown')
});
MemDB.allDbs(function(error, result) {
console.log(result);
});
Then install dependencies:
npm install pouchdb pouchdb-all-dbs memdown
Verify that we have the proper files in the test direcotry:
$ ls -la
total 28
drwxr-sr-x 3 jonhall jonhall 4096 Feb 11 19:20 .
drwxrwsr-x 132 jonhall jonhall 16384 Feb 11 19:19 ..
drwxr-sr-x 206 jonhall jonhall 4096 Feb 11 19:20 node_modules
-rw-r--r-- 1 jonhall jonhall 203 Feb 11 19:19 test.js
Then run the test script:
$ node ./test.js
[]
No output, as expected, but now do another ls:
$ ls -la
total 32
drwxr-sr-x 4 jonhall jonhall 4096 Feb 11 19:21 .
drwxrwsr-x 132 jonhall jonhall 16384 Feb 11 19:19 ..
drwxr-sr-x 206 jonhall jonhall 4096 Feb 11 19:20 node_modules
drwxr-sr-x 2 jonhall jonhall 4096 Feb 11 19:21 pouch__all_dbs__
-rw-r--r-- 1 jonhall jonhall 203 Feb 11 19:19 test.js
Notice the new pouch__all_dbs__ directory, thus proving that allDbs() is still using the filesystem instead of memdown. Is this a bug? Is there a workaround?