allow using pg environment variables as test connection parameters
This commit is contained in:
parent
5ca05e9cfe
commit
550617f6ad
6
Makefile
6
Makefile
@ -1,12 +1,16 @@
|
|||||||
SHELL := /bin/bash
|
SHELL := /bin/bash
|
||||||
|
|
||||||
connectionString=pg://postgres:5432@localhost/postgres
|
connectionString=pg://
|
||||||
|
|
||||||
params := $(connectionString)
|
params := $(connectionString)
|
||||||
|
|
||||||
node-command := xargs -n 1 -I file node file $(params)
|
node-command := xargs -n 1 -I file node file $(params)
|
||||||
|
|
||||||
.PHONY : test test-connection test-integration bench test-native build/default/binding.node
|
.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: test-unit
|
||||||
|
|
||||||
test-all: test-unit test-integration test-native test-binary
|
test-all: test-unit test-integration test-native test-binary
|
||||||
|
12
test/cli.js
12
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++) {
|
for(var i = 0; i < process.argv.length; i++) {
|
||||||
switch(process.argv[i].toLowerCase()) {
|
switch(process.argv[i].toLowerCase()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user