mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
fix(tests): never connect to NODE_DB_URI for tests
This commit is contained in:
@@ -26,10 +26,10 @@ if (process.env.LOAD_SERVER === '0') { // when the server is in a different proc
|
|||||||
require('../../website/server/libs/api-v3/setupNconf')('./config.json');
|
require('../../website/server/libs/api-v3/setupNconf')('./config.json');
|
||||||
// Use Q promises instead of mpromise in mongoose
|
// Use Q promises instead of mpromise in mongoose
|
||||||
mongoose.Promise = Bluebird;
|
mongoose.Promise = Bluebird;
|
||||||
mongoose.connect(nconf.get('NODE_DB_URI'));
|
mongoose.connect(nconf.get('TEST_DB_URI'));
|
||||||
} else { // When running tests and the server in the same process
|
} else { // When running tests and the server in the same process
|
||||||
require('../../website/server/libs/api-v3/setupNconf')('./config.json.example');
|
require('../../website/server/libs/api-v3/setupNconf')('./config.json.example');
|
||||||
nconf.set('NODE_DB_URI', 'mongodb://localhost/habitrpg_test');
|
nconf.set('NODE_DB_URI', nconf.get('TEST_DB_URI'));
|
||||||
nconf.set('NODE_ENV', 'test');
|
nconf.set('NODE_ENV', 'test');
|
||||||
nconf.set('IS_TEST', true);
|
nconf.set('IS_TEST', true);
|
||||||
// We require src/server and npt src/index because
|
// We require src/server and npt src/index because
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ let mongooseOptions = !IS_PROD ? {} : {
|
|||||||
replset: { socketOptions: { keepAlive: 120, connectTimeoutMS: 30000 } },
|
replset: { socketOptions: { keepAlive: 120, connectTimeoutMS: 30000 } },
|
||||||
server: { socketOptions: { keepAlive: 120, connectTimeoutMS: 30000 } },
|
server: { socketOptions: { keepAlive: 120, connectTimeoutMS: 30000 } },
|
||||||
};
|
};
|
||||||
let db = mongoose.connect(nconf.get('NODE_DB_URI'), mongooseOptions, (err) => {
|
|
||||||
|
const NODE_DB_URI = nconf.get('IS_TEST') ? nconf.get('TEST_DB_URI') : nconf.get('NODE_DB_URI');
|
||||||
|
let db = mongoose.connect(NODE_DB_URI, mongooseOptions, (err) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
logger.info('Connected with Mongoose.');
|
logger.info('Connected with Mongoose.');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user