Skip to content

Commit a107f86

Browse files
committed
Use in-memory dbs for most of the test suite
The only thing left to do is to refactor z-webmention-test. I tried but I got eaten by a grue. Ref #31
1 parent 2605d5a commit a107f86

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

test/lib/app.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@
2626

2727
var assert = require('perjury').assert,
2828
noopLog = require('./log'),
29+
memoryPersistence = require('./persistence').memoryPersistence,
2930
_ = require('lodash');
3031

3132
function configureAppSetup(config) {
3233
return {
3334
topic: function() {
3435
var app = require('../../lib/app').makeApp(_.defaults(config, {
3536
domains: []
36-
}), noopLog, require('../../lib/persistence')('/tmp')),
37+
}), noopLog, memoryPersistence()),
3738
cb = this.callback;
3839

3940
var server = app.listen(config.port || 5320, config.address || 'localhost', function(err) {

test/lib/persistence.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,22 @@ function wrapFsMocks(configurePath, obj) {
5555
return _.assign({}, buildMockSetup(configurePath), obj);
5656
}
5757

58+
function makeInMemoryPersistence() {
59+
var store = new Map();
60+
61+
return function() {
62+
return {
63+
get: function(namespace, key, cb) {
64+
process.nextTick(cb.bind(undefined, undefined, store.get(namespace + key) || {}));
65+
},
66+
set: function(namespace, key, data, cb) {
67+
store.set(namespace + key, data);
68+
process.nextTick(cb);
69+
70+
}
71+
};
72+
};
73+
}
74+
5875
module.exports.wrapFsMocks = wrapFsMocks;
76+
module.exports.memoryPersistence = makeInMemoryPersistence;

0 commit comments

Comments
 (0)