mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-01-25 17:56:17 +00:00
add db init method, prepare for db testing
This commit is contained in:
parent
f38275a0f9
commit
cec79bdc75
8
app.js
8
app.js
@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var http = require('http'),
|
||||
var db = require('./db'),
|
||||
http = require('http'),
|
||||
nodeStatic = require('node-static'),
|
||||
jade = require('jade'),
|
||||
path = require('path'),
|
||||
@ -72,6 +73,11 @@ Steppy(
|
||||
console.log('Server config:', JSON.stringify(app.config, null, 4));
|
||||
|
||||
notifier.init(app.config.notify, this.slot());
|
||||
|
||||
db.init('path/to/db/ignored/for/memdown', {
|
||||
db: require('memdown'),
|
||||
valueEncoding: 'json'
|
||||
}, this.slot());
|
||||
},
|
||||
function() {
|
||||
// load all projects for the first time
|
||||
|
20
db.js
20
db.js
@ -2,11 +2,11 @@
|
||||
|
||||
var Steppy = require('twostep').Steppy,
|
||||
_ = require('underscore'),
|
||||
nlevel = require('nlevel'),
|
||||
ldb = nlevel.db('path/to/db/ignored/for/memdown', {
|
||||
db: require('memdown'),
|
||||
valueEncoding: 'json'
|
||||
});
|
||||
nlevel = require('nlevel');
|
||||
|
||||
|
||||
exports.init = function(dbPath, params, callback) {
|
||||
var ldb = nlevel.db(dbPath, params, callback);
|
||||
|
||||
exports.builds = new nlevel.DocsSection(ldb, 'builds', {
|
||||
projections: [
|
||||
@ -26,10 +26,6 @@ exports.builds = new nlevel.DocsSection(ldb, 'builds', {
|
||||
]
|
||||
});
|
||||
|
||||
function pickProjectName(build) {
|
||||
return build.project.name;
|
||||
}
|
||||
|
||||
exports.builds._beforePut = function(builds, callback) {
|
||||
var self = this,
|
||||
build;
|
||||
@ -68,6 +64,12 @@ exports.builds._beforePut = function(builds, callback) {
|
||||
callback
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
function pickProjectName(build) {
|
||||
return build.project.name;
|
||||
}
|
||||
|
||||
|
||||
function generateIds(section, docs, callback) {
|
||||
Steppy(
|
||||
|
5
test/db/concurrent.js
Normal file
5
test/db/concurrent.js
Normal file
@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
describe('Db concurrency', function() {
|
||||
|
||||
});
|
3
test/db/index.js
Normal file
3
test/db/index.js
Normal file
@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
require('./concurrent');
|
@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
require('./commands');
|
||||
require('./db');
|
||||
require('./scm');
|
||||
require('./executor');
|
||||
require('./node');
|
||||
|
Loading…
Reference in New Issue
Block a user