node-query/tests/adapters/mysql2_test.js

40 lines
1004 B
JavaScript
Raw Normal View History

2014-10-23 10:53:16 -04:00
'use strict';
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';
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');
var qb = nodeQuery('mysql', connection, adapterName);
// Set up the test base
testBase._setUp(qb, function(test, err, rows) {
if (err != null) {
test.done();
2014-10-23 10:53:16 -04:00
throw new Error(err);
}
test.ok(rows, 'Valid result for generated query');
test.done();
2014-10-23 10:53:16 -04:00
});
// Export the final test object
tests["mysql2 adapter with query builder"] = function(test) {
test.ok(testBase.qb);
test.done();
};
module.exports = tests;