node-query/tests/adapters/mysql_test.js

49 lines
1.2 KiB
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 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 = 'mysql';
var config = require(configFile)[adapterName];
2014-10-23 10:53:16 -04:00
// Set up the connection
var mysql = require(adapterName);
var connection = mysql.createConnection(config.conn);
// Set up the query builder object
var nodeQuery = require('../../lib/node-query');
var qb = nodeQuery.init('mysql', connection, adapterName);
2014-10-23 10:53:16 -04:00
// 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, 'mysql: Valid result for generated query');
test.done();
2014-10-23 10:53:16 -04: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
tests["mysql adapter with query builder"] = function(test) {
test.expect(1);
2014-10-23 10:53:16 -04:00
test.ok(testBase.qb);
2014-11-04 13:07:43 -05:00
test.done();
// Close the db connection
connection.end();
2014-10-23 10:53:16 -04:00
};
// Export the final test object
module.exports = tests;