node-postgres/test/integration/test-helper.js
Brian C a536afb1a8 Add callback to client#end (#1106)
A long standing bug was the pure JS client didn't accept or call a callback on `client.end`.  This is inconsistent with both the documentation & general node patterns.

This fixes the issue & adds a test.  The issue did not exist in the native version of the client.
2016-08-11 10:17:03 -05:00

28 lines
736 B
JavaScript

var helper = require(__dirname + '/../test-helper');
if(helper.args.native) {
Client = require(__dirname + '/../../lib/native');
helper.Client = Client;
helper.pg = helper.pg.native;
}
//creates a client from cli parameters
helper.client = function(cb) {
var client = new Client(helper.config);
client.connect(cb);
return client;
};
var semver = require('semver');
helper.versionGTE = function(client, versionString, callback) {
client.query('SELECT version()', assert.calls(function(err, result) {
if(err) return callback(err);
var version = result.rows[0].version.split(' ')[1];
return callback(null, semver.gte(version, versionString));
}));
};
//export parent helper stuffs
module.exports = helper;