2010-12-20 05:12:51 +08:00
|
|
|
var helper = require(__dirname + '/../test/test-helper');
|
2011-11-22 11:42:43 +08:00
|
|
|
|
2010-12-20 05:12:51 +08:00
|
|
|
console.log();
|
2011-11-22 11:42:43 +08:00
|
|
|
console.log("testing ability to connect to '%j'", helper.config);
|
2010-12-20 05:12:51 +08:00
|
|
|
var pg = require(__dirname + '/../lib');
|
2013-03-08 05:57:00 +08:00
|
|
|
pg.connect(helper.config, function(err, client, done) {
|
2010-12-20 05:12:51 +08:00
|
|
|
if(err !== null) {
|
|
|
|
console.error("Recieved connection error when attempting to contact PostgreSQL:");
|
|
|
|
console.error(err);
|
|
|
|
process.exit(255);
|
|
|
|
}
|
|
|
|
console.log("Checking for existance of required test table 'person'")
|
|
|
|
client.query("SELECT COUNT(name) FROM person", function(err, callback) {
|
|
|
|
if(err != null) {
|
|
|
|
console.error("Recieved error when executing query 'SELECT COUNT(name) FROM person'")
|
|
|
|
console.error("It is possible you have not yet run the table create script under script/create-test-tables")
|
|
|
|
console.error("Consult the postgres-node wiki under the 'Testing' section for more information")
|
|
|
|
console.error(err);
|
|
|
|
process.exit(255);
|
|
|
|
}
|
2013-03-08 05:57:00 +08:00
|
|
|
done();
|
2010-12-20 05:12:51 +08:00
|
|
|
pg.end();
|
|
|
|
})
|
|
|
|
})
|