loopback-connector-mysql/test/init.js

33 lines
682 B
JavaScript

module.exports = require('should');
var DataSource = require('loopback-datasource-juggler').DataSource;
var config = require('rc')('loopback', {test: {mysql: {}}}).test.mysql;
global.getConfig = function (options) {
var dbConf = {
host: config.host || 'localhost',
port: config.port || 3306,
database: 'myapp_test',
username: config.username,
password: config.password,
createDatabase: true
};
if (options) {
for (var el in options) {
dbConf[el] = options[el];
}
}
return dbConf;
};
global.getDataSource = global.getSchema = function (options) {
var db = new DataSource(require('../'), getConfig(options));
return db;
};