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
|
|
|
|
};
|
|
|
|
|
2014-04-25 13:45:34 +08:00
|
|
|
test('uses password file when PGPASSFILE env variable is set', function() {
|
|
|
|
// connect & disconnect from heroku
|
|
|
|
pg.connect(config, assert.calls(function(err, client, done) {
|
|
|
|
assert.isNull(err);
|
|
|
|
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();
|
|
|
|
}))
|
2014-05-02 12:32:15 +08:00
|
|
|
}));
|
2014-04-25 13:45:34 +08:00
|
|
|
});
|