Configuración en entorno test

This commit is contained in:
Joan Sanchez 2017-12-27 09:44:27 +01:00
parent de3d294cdb
commit 21894ca0f8
5 changed files with 30 additions and 18 deletions

View File

@ -1,15 +1,20 @@
var path = require('path'); var path = require('path');
var fs = require('fs'); let defaultFile = 'datasources.json';
var config = {};
let devConfigPath = path.join(__dirname, '/config/datasources.development.json'); function getFile(fileName) {
let configPath = path.join(__dirname, '/config/datasources.json'); return require(path.join(__dirname, `/config/${fileName}`));
}
try { try {
config = Object.assign(require(configPath), require(devConfigPath)); let envFile = 'datasources.development.json';
if (process.env.NODE_ENV === 'test')
envFile = 'datasources.test.json';
config = getFile(envFile);
} catch (e) { } catch (e) {
if (e.code == 'MODULE_NOT_FOUND') if (e.code == 'MODULE_NOT_FOUND')
config = require(configPath); config = getFile(defaultFile);
} }
config.proxy = require('../../nginx/config.json'); config.proxy = require('../../nginx/config.json');

View File

@ -4,14 +4,14 @@
"debug": false, "debug": false,
"defaultLanguage": "es", "defaultLanguage": "es",
"senderMail": "noreply@localhost", "senderMail": "noreply@localhost",
"senderName": "" "senderName": "VerdNatura"
}, },
"mysql": { "mysql": {
"host": "localhost", "host": "localhost",
"port": 3306, "port": 3306,
"user": "reports", "user": "root",
"password": "", "password": "",
"database": "" "database": "vn"
}, },
"smtp": { "smtp": {
"host": "localhost", "host": "localhost",

View File

@ -12,15 +12,17 @@ module.exports = {
* Load mail config. * Load mail config.
*/ */
init: function() { init: function() {
this.transporter = nodemailer.createTransport(config.smtp); this.transporter = nodemailer.createTransport(config.smtp);
this.transporter.verify(function(error, success) { this.transporter.verify(function(error, success) {
if (error) { if (error) {
throw new Error(error); console.error(error);
} else if (config.app.debug) { } else if (config.app.debug) {
console.log('SMTP connection stablished'); console.log('SMTP connection stablished');
} }
}); });
}, },
/** /**

View File

@ -1,15 +1,20 @@
var path = require('path'); var path = require('path');
var fs = require('fs'); let defaultFile = 'datasources.json';
var config = {};
let devConfigPath = path.join(__dirname, '/config/datasources.development.json'); function getFile(fileName) {
let configPath = path.join(__dirname, '/config/datasources.json'); return require(path.join(__dirname, `/config/${fileName}`));
}
try { try {
config = Object.assign(require(configPath), require(devConfigPath)); let envFile = 'datasources.development.json';
if (process.env.NODE_ENV === 'test')
envFile = 'datasources.test.json';
config = getFile(envFile);
} catch (e) { } catch (e) {
if (e.code == 'MODULE_NOT_FOUND') if (e.code == 'MODULE_NOT_FOUND')
config = require(configPath); config = getFile(defaultFile);
} }
config.proxy = require('../../nginx/config.json'); config.proxy = require('../../nginx/config.json');

View File

@ -7,9 +7,9 @@
"mysql": { "mysql": {
"host": "localhost", "host": "localhost",
"port": 3306, "port": 3306,
"user": "reports", "user": "root",
"password": "", "password": "",
"database": "" "database": "vn"
}, },
"pdf": { "pdf": {
"footer": { "footer": {