|
|
@ -5,12 +5,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
(function (module) {
|
|
|
|
(function (module) {
|
|
|
|
'use strict';
|
|
|
|
'use strict';
|
|
|
|
/*global require, before*/
|
|
|
|
/*global require, before, __dirname*/
|
|
|
|
|
|
|
|
|
|
|
|
var path = require('path'),
|
|
|
|
var async = require('async');
|
|
|
|
nconf = require('nconf'),
|
|
|
|
var path = require('path');
|
|
|
|
winston = require('winston'),
|
|
|
|
var nconf = require('nconf');
|
|
|
|
errorText;
|
|
|
|
var winston = require('winston');
|
|
|
|
|
|
|
|
var errorText;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nconf.file({ file: path.join(__dirname, '../../config.json') });
|
|
|
|
nconf.file({ file: path.join(__dirname, '../../config.json') });
|
|
|
@ -22,11 +23,11 @@
|
|
|
|
relative_path: ''
|
|
|
|
relative_path: ''
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var dbType = nconf.get('database'),
|
|
|
|
var dbType = nconf.get('database');
|
|
|
|
testDbConfig = nconf.get('test_database'),
|
|
|
|
var testDbConfig = nconf.get('test_database');
|
|
|
|
productionDbConfig = nconf.get(dbType);
|
|
|
|
var productionDbConfig = nconf.get(dbType);
|
|
|
|
|
|
|
|
|
|
|
|
if(!testDbConfig){
|
|
|
|
if (!testDbConfig){
|
|
|
|
errorText = 'test_database is not defined';
|
|
|
|
errorText = 'test_database is not defined';
|
|
|
|
winston.info(
|
|
|
|
winston.info(
|
|
|
|
'\n===========================================================\n' +
|
|
|
|
'\n===========================================================\n' +
|
|
|
@ -59,10 +60,9 @@
|
|
|
|
throw new Error(errorText);
|
|
|
|
throw new Error(errorText);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if( testDbConfig.database === productionDbConfig.database &&
|
|
|
|
if (testDbConfig.database === productionDbConfig.database &&
|
|
|
|
testDbConfig.host === productionDbConfig.host &&
|
|
|
|
testDbConfig.host === productionDbConfig.host &&
|
|
|
|
testDbConfig.port === productionDbConfig.port
|
|
|
|
testDbConfig.port === productionDbConfig.port) {
|
|
|
|
){
|
|
|
|
|
|
|
|
errorText = 'test_database has the same config as production db';
|
|
|
|
errorText = 'test_database has the same config as production db';
|
|
|
|
winston.error(errorText);
|
|
|
|
winston.error(errorText);
|
|
|
|
throw new Error(errorText);
|
|
|
|
throw new Error(errorText);
|
|
|
@ -70,38 +70,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
nconf.set(dbType, testDbConfig);
|
|
|
|
nconf.set(dbType, testDbConfig);
|
|
|
|
|
|
|
|
|
|
|
|
var db = require('../../src/database'),
|
|
|
|
var db = require('../../src/database');
|
|
|
|
meta = require('../../src/meta');
|
|
|
|
var meta = require('../../src/meta');
|
|
|
|
|
|
|
|
|
|
|
|
before(function (done) {
|
|
|
|
before(function (done) {
|
|
|
|
db.init(function (err) {
|
|
|
|
async.waterfall([
|
|
|
|
if (err) {
|
|
|
|
function (next) {
|
|
|
|
return done(err);
|
|
|
|
db.init(next);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
function (next) {
|
|
|
|
//Clean up
|
|
|
|
db.flushdb(next);
|
|
|
|
db.flushdb(function (err) {
|
|
|
|
},
|
|
|
|
if(err) {
|
|
|
|
function (next) {
|
|
|
|
winston.error(err);
|
|
|
|
|
|
|
|
throw new Error(err);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
winston.info('test_database flushed');
|
|
|
|
winston.info('test_database flushed');
|
|
|
|
|
|
|
|
meta.configs.init(next);
|
|
|
|
meta.configs.init(function () {
|
|
|
|
},
|
|
|
|
nconf.set('url', nconf.get('base_url') + (nconf.get('use_port') ? ':' + nconf.get('port') : '') + nconf.get('relative_path'));
|
|
|
|
function (next) {
|
|
|
|
nconf.set('core_templates_path', path.join(__dirname, '../../src/views'));
|
|
|
|
nconf.set('url', nconf.get('base_url') + (nconf.get('use_port') ? ':' + nconf.get('port') : '') + nconf.get('relative_path'));
|
|
|
|
nconf.set('base_templates_path', path.join(nconf.get('themes_path'), 'nodebb-theme-vanilla/templates'));
|
|
|
|
nconf.set('core_templates_path', path.join(__dirname, '../../src/views'));
|
|
|
|
nconf.set('theme_templates_path', meta.config['theme:templates'] ? path.join(nconf.get('themes_path'), meta.config['theme:id'], meta.config['theme:templates']) : nconf.get('base_templates_path'));
|
|
|
|
nconf.set('base_templates_path', path.join(nconf.get('themes_path'), 'nodebb-theme-vanilla/templates'));
|
|
|
|
|
|
|
|
nconf.set('theme_templates_path', meta.config['theme:templates'] ? path.join(nconf.get('themes_path'), meta.config['theme:id'], meta.config['theme:templates']) : nconf.get('base_templates_path'));
|
|
|
|
var webserver = require('../../src/webserver'),
|
|
|
|
|
|
|
|
sockets = require('../../src/socket.io');
|
|
|
|
var webserver = require('../../src/webserver');
|
|
|
|
sockets.init(webserver.server);
|
|
|
|
var sockets = require('../../src/socket.io');
|
|
|
|
|
|
|
|
sockets.init(webserver.server);
|
|
|
|
done();
|
|
|
|
|
|
|
|
});
|
|
|
|
require('../../src/notifications').init();
|
|
|
|
});
|
|
|
|
require('../../src/user').startJobs();
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
webserver.listen();
|
|
|
|
|
|
|
|
next();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
], done);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = db;
|
|
|
|
module.exports = db;
|
|
|
|