2010-12-15 09:30:32 +08:00
|
|
|
var helper = require(__dirname + '/test-helper')
|
|
|
|
|
|
|
|
var called = false;
|
|
|
|
test('disconnects', function() {
|
|
|
|
var sink = new helper.Sink(4, function() {
|
|
|
|
called = true;
|
2014-04-17 16:18:49 +08:00
|
|
|
var eventSink = new helper.Sink(1, function() {});
|
|
|
|
helper.pg.on('ended', function() {
|
|
|
|
eventSink.add();
|
|
|
|
});
|
|
|
|
|
2010-12-15 09:30:32 +08:00
|
|
|
//this should exit the process, killing each connection pool
|
|
|
|
helper.pg.end();
|
|
|
|
});
|
2011-11-22 11:42:43 +08:00
|
|
|
[helper.config, helper.config, helper.config, helper.config].forEach(function(config) {
|
2013-03-08 05:57:00 +08:00
|
|
|
helper.pg.connect(config, function(err, client, done) {
|
2010-12-15 09:30:32 +08:00
|
|
|
assert.isNull(err);
|
|
|
|
client.query("SELECT * FROM NOW()", function(err, result) {
|
2013-12-06 11:25:46 +08:00
|
|
|
setTimeout(function() {
|
2010-12-15 09:30:32 +08:00
|
|
|
assert.equal(called, false, "Should not have disconnected yet")
|
|
|
|
sink.add();
|
2013-03-08 05:57:00 +08:00
|
|
|
done();
|
2013-12-06 11:25:46 +08:00
|
|
|
}, 0)
|
2010-12-15 09:30:32 +08:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|