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 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 = 'pg';
|
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 pg = require(adapterName);
|
|
|
|
var connection = new pg.Client(config.conn);
|
2014-10-27 15:46:54 -04:00
|
|
|
connection.connect(function(err) {
|
|
|
|
if (err) {
|
|
|
|
throw new Error(err);
|
|
|
|
}
|
|
|
|
});
|
2014-10-23 10:53:16 -04:00
|
|
|
|
|
|
|
// Set up the query builder object
|
|
|
|
var nodeQuery = require('../../lib/node-query');
|
2014-11-03 10:59:18 -05:00
|
|
|
var qb = nodeQuery.init('pg', connection, adapterName);
|
2014-10-23 10:53:16 -04:00
|
|
|
|
|
|
|
|
|
|
|
// Set up the test base
|
2014-10-24 14:26:31 -04:00
|
|
|
testBase._setUp(qb, function(test, err, result) {
|
2014-10-27 15:46:54 -04:00
|
|
|
if (err != null) {
|
|
|
|
console.error('SQL syntax error', err);
|
2014-10-23 10:53:16 -04:00
|
|
|
}
|
|
|
|
|
2014-10-28 14:40:03 -04:00
|
|
|
test.ok(result, 'pg: Valid result for generated query');
|
2014-10-27 15:46:54 -04:00
|
|
|
test.done();
|
2014-10-23 10:53:16 -04:00
|
|
|
});
|
|
|
|
|
2014-10-27 15:46:54 -04:00
|
|
|
|
2014-10-23 10:53:16 -04:00
|
|
|
tests["pg 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();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = tests;
|