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

37 lines
852 B
JavaScript
Raw Normal View History

2013-12-06 07:01:51 +08:00
var helper = require(__dirname + '/../test-helper');
// Path to the password file
var passfile = __dirname + '/heroku.pgpass';
// Export the path to the password file
process.env.PGPASSFILE = passfile;
2013-12-11 08:24:55 +08:00
// Do a chmod 660, because git doesn't track those permissions
2013-12-06 07:01:51 +08:00
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();
}))
}));