2014-10-23 10:53:16 -04:00
|
|
|
'use strict';
|
|
|
|
|
2014-10-27 16:07:07 -04:00
|
|
|
var configFile = (process.env.CI) ? '../config-travis.json' : '../config.json';
|
|
|
|
|
2014-10-23 10:53:16 -04:00
|
|
|
// Load a fresh version of the test base
|
|
|
|
delete require.cache[require.resolve('../query-builder-base')];
|
|
|
|
var testBase = require('../query-builder-base');
|
|
|
|
var tests = testBase.tests;
|
|
|
|
|
|
|
|
// Load the test config file
|
|
|
|
var adapterName = 'mysql2';
|
2014-10-27 16:07:07 -04:00
|
|
|
var config = require(configFile)[adapterName];
|
2014-10-23 10:53:16 -04:00
|
|
|
|
|
|
|
// Set up the connection
|
|
|
|
var mysql2 = require(adapterName);
|
|
|
|
var connection = mysql2.createConnection(config.conn);
|
|
|
|
|
|
|
|
// Set up the query builder object
|
|
|
|
var nodeQuery = require('../../lib/node-query');
|
2014-11-03 10:59:18 -05:00
|
|
|
var qb = nodeQuery.init('mysql', connection, adapterName);
|
2014-10-23 10:53:16 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2014-11-05 17:08:56 -05:00
|
|
|
tests['nodeQuery.getQuery = nodeQuery.init'] = function(test) {
|
|
|
|
test.expect(1);
|
|
|
|
test.deepEqual(qb, nodeQuery.getQuery(), "getQuery returns same object");
|
|
|
|
test.done();
|
|
|
|
};
|
|
|
|
|
2014-10-23 10:53:16 -04:00
|
|
|
// Export the final test object
|
|
|
|
tests["mysql2 adapter with query builder"] = function(test) {
|
2014-10-28 16:46:48 -04:00
|
|
|
test.expect(1);
|
2014-10-23 10:53:16 -04:00
|
|
|
test.ok(testBase.qb);
|
2014-10-28 16:46:48 -04:00
|
|
|
|
|
|
|
// Close the db connection
|
|
|
|
connection.end();
|
2014-10-23 10:53:16 -04:00
|
|
|
test.done();
|
|
|
|
};
|
|
|
|
|
2015-11-20 09:14:09 -05:00
|
|
|
// Set up the test base
|
|
|
|
testBase._setUp(qb, function(test, err, rows) {
|
|
|
|
if (err != null) {
|
|
|
|
test.done();
|
|
|
|
throw new Error(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
test.ok(rows, 'mysql2: Invalid result for generated query');
|
|
|
|
test.done();
|
|
|
|
});
|
2014-10-23 10:53:16 -04:00
|
|
|
|
|
|
|
module.exports = tests;
|