node-postgres/test/integration/test-helper.js

28 lines
732 B
JavaScript
Raw Normal View History

2010-10-25 14:30:14 +08:00
var helper = require(__dirname + '/../test-helper');
if(helper.args.native) {
Client = require(__dirname + '/../../lib/native');
2012-05-31 11:40:49 +08:00
helper.Client = Client;
helper.pg = helper.pg.native;
}
2012-05-31 11:40:49 +08:00
//creates a client from cli parameters
helper.client = function() {
var client = new Client(helper.config);
client.connect();
return client;
};
2013-04-17 22:26:31 +08:00
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));
}));
};
2010-10-25 14:30:14 +08:00
//export parent helper stuffs
2010-12-14 07:21:09 +08:00
module.exports = helper;