2014-09-01 17:18:45 +02:00
|
|
|
/*global expect*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
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');
|
|
|
|
|
2014-08-11 12:25:39 +02:00
|
|
|
// excluding oracle and maria dialects from default integrations test
|
2014-09-01 17:18:45 +02:00
|
|
|
var testIntegrationDialects = (process.env.KNEX_TEST_INTEGRATION_DIALECTS || "mysql mysql2 postgres sqlite3").match(/\w+/g);
|
2014-08-11 12:25:39 +02:00
|
|
|
|
2014-05-28 22:29:34 -04:00
|
|
|
var pool = {
|
|
|
|
afterCreate: function(connection, callback) {
|
|
|
|
expect(connection).to.have.property('__cid');
|
|
|
|
callback(null, connection);
|
|
|
|
},
|
2014-08-28 20:34:09 +02:00
|
|
|
beforeDestroy: function(connection, continueFunc) {
|
2014-05-28 22:29:34 -04:00
|
|
|
expect(connection).to.have.property('__cid');
|
2014-08-28 20:34:09 +02:00
|
|
|
continueFunc();
|
2014-05-28 22:29:34 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var migrations = {
|
2014-07-21 19:56:42 -04:00
|
|
|
directory: 'test/integration/migrate/migration'
|
2014-05-28 22:29:34 -04:00
|
|
|
};
|
|
|
|
|
2014-07-21 18:38:40 -04:00
|
|
|
var seeds = {
|
2014-07-21 19:56:42 -04:00
|
|
|
directory: 'test/integration/seed/seeds'
|
2014-07-21 18:38:40 -04:00
|
|
|
};
|
|
|
|
|
2014-08-11 12:25:39 +02:00
|
|
|
var testConfigs = {
|
2014-06-03 23:27:37 -04:00
|
|
|
maria: {
|
2014-07-09 10:36:40 -04:00
|
|
|
dialect: 'maria',
|
2014-06-03 23:27:37 -04:00
|
|
|
connection: testConfig.maria || {
|
|
|
|
db: "knex_test",
|
|
|
|
user: "root",
|
|
|
|
charset: 'utf8'
|
|
|
|
},
|
2014-07-21 18:38:40 -04:00
|
|
|
migrations: migrations,
|
|
|
|
seeds: seeds
|
2014-06-03 23:27:37 -04:00
|
|
|
},
|
|
|
|
|
2014-05-28 22:29:34 -04:00
|
|
|
mysql: {
|
2014-07-09 10:36:40 -04:00
|
|
|
dialect: 'mysql',
|
2014-05-28 22:29:34 -04:00
|
|
|
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);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
2014-07-21 18:38:40 -04:00
|
|
|
migrations: migrations,
|
|
|
|
seeds: seeds
|
2014-05-28 22:29:34 -04:00
|
|
|
},
|
|
|
|
|
2014-06-09 16:27:03 -04:00
|
|
|
mysql2: {
|
2014-07-09 10:36:40 -04:00
|
|
|
dialect: 'mysql2',
|
2014-06-09 16:27:03 -04:00
|
|
|
connection: testConfig.mysql || {
|
|
|
|
database: "knex_test",
|
|
|
|
user: "root",
|
|
|
|
charset: 'utf8'
|
|
|
|
},
|
|
|
|
pool: _.extend({}, pool, {
|
|
|
|
afterCreate: function(connection, callback) {
|
|
|
|
Promise.promisify(connection.query, connection)("SET sql_mode='TRADITIONAL';", []).then(function() {
|
|
|
|
callback(null, connection);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
2014-07-21 18:38:40 -04:00
|
|
|
migrations: migrations,
|
|
|
|
seeds: seeds
|
2014-06-09 16:27:03 -04:00
|
|
|
},
|
|
|
|
|
2014-08-11 12:25:39 +02:00
|
|
|
oracle: {
|
|
|
|
dialect: 'oracle',
|
|
|
|
connection: testConfig.oracle || {
|
|
|
|
adapter: "oracle",
|
|
|
|
database: "knex_test",
|
|
|
|
user: "oracle"
|
|
|
|
},
|
|
|
|
pool: pool,
|
|
|
|
migrations: migrations
|
|
|
|
},
|
2014-06-09 16:27:03 -04:00
|
|
|
|
2014-05-28 22:29:34 -04:00
|
|
|
postgres: {
|
2014-07-09 10:36:40 -04:00
|
|
|
dialect: 'postgres',
|
2014-05-28 22:29:34 -04:00
|
|
|
connection: testConfig.postgres || {
|
|
|
|
adapter: "postgresql",
|
|
|
|
database: "knex_test",
|
|
|
|
user: "postgres"
|
|
|
|
},
|
|
|
|
pool: pool,
|
2014-07-21 18:38:40 -04:00
|
|
|
migrations: migrations,
|
|
|
|
seeds: seeds
|
2014-05-28 22:29:34 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
sqlite3: {
|
2014-07-09 10:36:40 -04:00
|
|
|
dialect: 'sqlite3',
|
2014-06-13 13:14:35 -04:00
|
|
|
connection: {
|
|
|
|
filename: __dirname + '/test.sqlite3'
|
2014-05-28 22:29:34 -04:00
|
|
|
},
|
2014-06-13 13:14:35 -04:00
|
|
|
pool: _.extend({}, pool, {
|
|
|
|
max: 2
|
|
|
|
}),
|
2014-07-21 18:38:40 -04:00
|
|
|
migrations: migrations,
|
|
|
|
seeds: seeds
|
2014-05-28 22:29:34 -04:00
|
|
|
}
|
2014-08-11 12:25:39 +02:00
|
|
|
};
|
2014-05-28 22:29:34 -04:00
|
|
|
|
2014-08-11 12:25:39 +02:00
|
|
|
// export only copy the specified dialects
|
|
|
|
module.exports = _.reduce(testIntegrationDialects, function (res, dialectName) {
|
|
|
|
res[dialectName] = testConfigs[dialectName];
|
|
|
|
return res;
|
|
|
|
}, {});
|