mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
made integration tests die faster when they cannot connect to the database
This commit is contained in:
parent
c0f37e1468
commit
7dc89cec04
5
Makefile
5
Makefile
@ -7,10 +7,13 @@ port=5432
|
||||
database=postgres
|
||||
verbose=false
|
||||
|
||||
test-connection:
|
||||
@node script/test-connection.js -u $(user) --password $(password) -p $(port) -d $(database) -h $(host) --verbose $(verbose)
|
||||
|
||||
test-unit:
|
||||
@find test/unit -name "*-tests.js" | xargs -n 1 -I file node file --verbose $(verbose)
|
||||
|
||||
test-integration:
|
||||
test-integration: test-connection
|
||||
@find test/integration -name "*-tests.js" | xargs -n 1 -I file node file -u $(user) --password $(password) -p $(port) -d $(database) -h $(host) --verbose $(verbose)
|
||||
|
||||
test-all: test-unit test-integration
|
||||
|
||||
23
script/test-connection.js
Normal file
23
script/test-connection.js
Normal file
@ -0,0 +1,23 @@
|
||||
var helper = require(__dirname + '/../test/test-helper');
|
||||
var connectionString = helper.connectionString();
|
||||
console.log();
|
||||
console.log("testing ability to connect to '%s'", connectionString);
|
||||
var pg = require(__dirname + '/../lib');
|
||||
pg.connect(connectionString, function(err, client) {
|
||||
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);
|
||||
}
|
||||
pg.end();
|
||||
})
|
||||
})
|
||||
@ -1,3 +1,6 @@
|
||||
var helper = require(__dirname + '/../test-helper');
|
||||
//export parent helper stuffs
|
||||
module.exports = helper;
|
||||
|
||||
if(helper.args.verbose) {
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user