Skip to content

Commit 550617f

Browse files
committed
allow using pg environment variables as test connection parameters
1 parent 5ca05e9 commit 550617f

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
SHELL := /bin/bash
22

3-
connectionString=pg://postgres:5432@localhost/postgres
3+
connectionString=pg://
44

55
params := $(connectionString)
66

77
node-command := xargs -n 1 -I file node file $(params)
88

99
.PHONY : test test-connection test-integration bench test-native build/default/binding.node
10+
11+
help:
12+
echo "make test-all connectionString=pg://<your connection string>"
13+
1014
test: test-unit
1115

1216
test-all: test-unit test-integration test-native test-binary

test/cli.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
var config = require(__dirname + '/../lib/utils').parseConnectionString(process.argv[2])
1+
var config = {};
2+
if(process.argv[2]) {
3+
config = require(__dirname + '/../lib/utils').parseConnectionString(process.argv[2]);
4+
}
5+
//TODO use these environment variables in lib/ code
6+
//http://www.postgresql.org/docs/8.4/static/libpq-envars.html
7+
config.host = config.host || process.env['PGHOST'] || process.env['PGHOSTADDR'];
8+
config.port = config.port || process.env['PGPORT'];
9+
config.database = config.database || process.env['PGDATABASE'];
10+
config.user = config.user || process.env['PGUSER'];
11+
config.password = config.password || process.env['PGPASSWORD'];
212

313
for(var i = 0; i < process.argv.length; i++) {
414
switch(process.argv[i].toLowerCase()) {

0 commit comments

Comments
 (0)