2010-10-25 14:30:14 +08:00
|
|
|
var helper = require(__dirname + '/../test-helper');
|
2011-03-04 02:21:43 +08:00
|
|
|
|
|
|
|
if(helper.args.native) {
|
2011-08-12 09:59:56 +08:00
|
|
|
Client = require(__dirname + '/../../lib/native');
|
2012-05-31 11:40:49 +08:00
|
|
|
helper.Client = Client;
|
2011-05-20 08:18:43 +08:00
|
|
|
helper.pg = helper.pg.native;
|
2011-03-04 02:21:43 +08:00
|
|
|
}
|
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;
|
2010-12-20 05:12:51 +08:00
|
|
|
|