allow using pg environment variables as test connection parameters

This commit is contained in:
brianc 2012-07-30 21:57:28 -05:00
parent 5ca05e9cfe
commit 550617f6ad
2 changed files with 16 additions and 2 deletions

View File

@ -1,12 +1,16 @@
SHELL := /bin/bash
connectionString=pg://postgres:5432@localhost/postgres
connectionString=pg://
params := $(connectionString)
node-command := xargs -n 1 -I file node file $(params)
.PHONY : test test-connection test-integration bench test-native build/default/binding.node
help:
echo "make test-all connectionString=pg://<your connection string>"
test: test-unit
test-all: test-unit test-integration test-native test-binary

View File

@ -1,4 +1,14 @@
var config = require(__dirname + '/../lib/utils').parseConnectionString(process.argv[2])
var config = {};
if(process.argv[2]) {
config = require(__dirname + '/../lib/utils').parseConnectionString(process.argv[2]);
}
//TODO use these environment variables in lib/ code
//http://www.postgresql.org/docs/8.4/static/libpq-envars.html
config.host = config.host || process.env['PGHOST'] || process.env['PGHOSTADDR'];
config.port = config.port || process.env['PGPORT'];
config.database = config.database || process.env['PGDATABASE'];
config.user = config.user || process.env['PGUSER'];
config.password = config.password || process.env['PGPASSWORD'];
for(var i = 0; i < process.argv.length; i++) {
switch(process.argv[i].toLowerCase()) {