Skip to content

Commit

Permalink
Use in-memory dbs for most of the test suite
Browse files Browse the repository at this point in the history
The only thing left to do is to refactor z-webmention-test. I tried
but I got eaten by a grue.

Ref #31
  • Loading branch information
strugee committed Dec 29, 2017
1 parent 2605d5a commit a107f86
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@

var assert = require('perjury').assert,
noopLog = require('./log'),
memoryPersistence = require('./persistence').memoryPersistence,
_ = require('lodash');

function configureAppSetup(config) {
return {
topic: function() {
var app = require('../../lib/app').makeApp(_.defaults(config, {
domains: []
}), noopLog, require('../../lib/persistence')('/tmp')),
}), noopLog, memoryPersistence()),
cb = this.callback;

var server = app.listen(config.port || 5320, config.address || 'localhost', function(err) {
Expand Down
18 changes: 18 additions & 0 deletions test/lib/persistence.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,22 @@ function wrapFsMocks(configurePath, obj) {
return _.assign({}, buildMockSetup(configurePath), obj);
}

function makeInMemoryPersistence() {
var store = new Map();

return function() {
return {
get: function(namespace, key, cb) {
process.nextTick(cb.bind(undefined, undefined, store.get(namespace + key) || {}));
},
set: function(namespace, key, data, cb) {
store.set(namespace + key, data);
process.nextTick(cb);

}
};
};
}

module.exports.wrapFsMocks = wrapFsMocks;
module.exports.memoryPersistence = makeInMemoryPersistence;

0 comments on commit a107f86

Please sign in to comment.