node-postgres/test/integration/client/heroku-pgpass-tests.js

43 lines
1019 B
JavaScript
Raw Normal View History

2013-12-06 07:01:51 +08:00
var helper = require(__dirname + '/../test-helper');
if (helper.args.native) {
// do not run testwith native bindings,
// see issue #475 (https://github.com/brianc/node-postgres/issues/475)
process.exit();
}
// Path to the password file
var passfile = __dirname + '/heroku.pgpass';
// Export the path to the password file
process.env.PGPASSFILE = passfile;
// Do a chmod 660, because git doesn't track thosepermissions
require('fs').chmodSync(passfile, 384);
var pg = helper.pg;
var host = 'ec2-107-20-224-218.compute-1.amazonaws.com';
var database = 'db6kfntl5qhp2';
var user = 'kwdzdnqpdiilfs';
var config = {
host: host,
database: database,
user: user,
ssl: true
};
// connect & disconnect from heroku
pg.connect(config, assert.success(function(client, done) {
client.query('SELECT NOW() as time', assert.success(function(res) {
assert(res.rows[0].time.getTime());
// cleanup ... remove the env variable
delete process.env.PGPASSFILE;
done();
pg.end();
}))
}));