loopback-connector-mysql/test/init.js

32 lines
702 B
JavaScript
Raw Normal View History

2013-04-07 21:53:55 +00:00
module.exports = require('should');
2013-08-22 04:53:48 +00:00
var DataSource = require('loopback-datasource-juggler').DataSource;
2013-08-23 21:31:43 +00:00
var config = require('rc')('loopback', {test: {mysql: {}}}).test.mysql;
2013-03-27 00:37:13 +00:00
2013-07-22 00:27:54 +00:00
global.getConfig = function(options) {
var dbConf = {
2013-08-22 04:53:48 +00:00
host: config.host || 'localhost',
port: config.port || 3306,
2013-07-22 00:27:54 +00:00
database: 'myapp_test',
2013-08-22 04:53:48 +00:00
username: config.username,
password: config.password
2013-07-22 00:27:54 +00:00
};
if (options) {
for (var el in options) {
2013-08-23 21:31:43 +00:00
dbConf[el] = options[el];
2013-07-22 00:27:54 +00:00
}
}
return dbConf;
2013-08-23 21:31:43 +00:00
};
2013-07-22 00:27:54 +00:00
2013-08-23 21:31:43 +00:00
global.getDataSource = global.getSchema = function(options) {
2013-08-22 04:53:48 +00:00
var db = new DataSource(require('../'), getConfig(options));
2013-03-27 00:37:13 +00:00
return db;
};
2013-07-22 00:27:54 +00:00