From 550617f6adf0040b116e2edf2ff1dfa77b290f57 Mon Sep 17 00:00:00 2001 From: brianc Date: Mon, 30 Jul 2012 21:57:28 -0500 Subject: [PATCH] allow using pg environment variables as test connection parameters --- Makefile | 6 +++++- test/cli.js | 12 +++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b7c98511..c1e79ec1 100644 --- a/Makefile +++ b/Makefile @@ -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://" + test: test-unit test-all: test-unit test-integration test-native test-binary diff --git a/test/cli.js b/test/cli.js index c35df8ef..45bb5ae7 100644 --- a/test/cli.js +++ b/test/cli.js @@ -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()) {