2014-05-28 22:29:34 -04:00
|
|
|
var testConfig = process.env.KNEX_TEST && require(process.env.KNEX_TEST) || {};
|
|
|
|
var _ = require('lodash');
|
|
|
|
var Promise = require('bluebird');
|
|
|
|
|
|
|
|
var pool = {
|
|
|
|
afterCreate: function(connection, callback) {
|
|
|
|
expect(connection).to.have.property('__cid');
|
|
|
|
callback(null, connection);
|
|
|
|
},
|
|
|
|
beforeDestroy: function(connection) {
|
|
|
|
expect(connection).to.have.property('__cid');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var migrations = {
|
|
|
|
directory: __dirname + '/integration/migrate/migration'
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
|
|
|
mysql: {
|
|
|
|
client: 'mysql',
|
|
|
|
connection: testConfig.mysql || {
|
|
|
|
database: "knex_test",
|
2014-06-03 09:56:37 -04:00
|
|
|
user: "root",
|
|
|
|
charset: 'utf8'
|
2014-05-28 22:29:34 -04:00
|
|
|
},
|
|
|
|
pool: _.extend({}, pool, {
|
|
|
|
afterCreate: function(connection, callback) {
|
|
|
|
Promise.promisify(connection.query, connection)("SET sql_mode='TRADITIONAL';", []).then(function() {
|
|
|
|
callback(null, connection);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
migrations: migrations
|
|
|
|
},
|
|
|
|
|
|
|
|
postgres: {
|
|
|
|
client: 'postgres',
|
|
|
|
connection: testConfig.postgres || {
|
|
|
|
adapter: "postgresql",
|
|
|
|
database: "knex_test",
|
|
|
|
user: "postgres"
|
|
|
|
},
|
|
|
|
pool: pool,
|
|
|
|
migrations: migrations
|
|
|
|
},
|
|
|
|
|
|
|
|
sqlite3: {
|
|
|
|
client: 'sqlite3',
|
2014-06-03 14:21:31 -04:00
|
|
|
connection: testConfig.sqlite3 || {
|
|
|
|
filename: ':memory:'
|
2014-05-28 22:29:34 -04:00
|
|
|
},
|
|
|
|
pool: pool,
|
|
|
|
migrations: migrations
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|