init.js
1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright IBM Corp. 2013,2016. All Rights Reserved.
// Node module: loopback-connector-mysql
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
module.exports = require('should');
var DataSource = require('loopback-datasource-juggler').DataSource;
var config = require('rc')('loopback', {test: {mysql: {}}}).test.mysql;
console.log(config);
global.getConfig = function(options) {
var dbConf = {
host: process.env.MYSQL_HOST || config.host || 'localhost',
port: process.env.MYSQL_PORT || config.port || 3306,
database: 'myapp_test',
username: process.env.MYSQL_USER || config.username,
password: process.env.MYSQL_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;
};
global.connectorCapabilities = {
ilike: false,
nilike: false,
};
global.sinon = require('sinon');