2010-12-14 07:21:40 +08:00
|
|
|
var helper = require(__dirname + "/../test-helper");
|
|
|
|
|
2011-11-22 11:42:43 +08:00
|
|
|
helper.testPoolSize = function(max) {
|
2010-12-14 07:21:40 +08:00
|
|
|
var sink = new helper.Sink(max, function() {
|
2011-11-22 11:42:43 +08:00
|
|
|
helper.pg.end();
|
2010-12-14 07:21:40 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
test("can pool " + max + " times", function() {
|
|
|
|
for(var i = 0; i < max; i++) {
|
|
|
|
helper.pg.poolSize = 10;
|
2010-12-15 09:23:01 +08:00
|
|
|
test("connection #" + i + " executes", function() {
|
2011-11-22 11:42:43 +08:00
|
|
|
helper.pg.connect(helper.config, function(err, client) {
|
2010-12-15 09:23:01 +08:00
|
|
|
assert.isNull(err);
|
|
|
|
client.query("select * from person", function(err, result) {
|
2011-10-11 08:21:06 +08:00
|
|
|
assert.lengthIs(result.rows, 26)
|
2010-12-15 09:23:01 +08:00
|
|
|
})
|
|
|
|
client.query("select count(*) as c from person", function(err, result) {
|
|
|
|
assert.equal(result.rows[0].c, 26)
|
|
|
|
})
|
|
|
|
var query = client.query("SELECT * FROM NOW()")
|
|
|
|
query.on('end',function() {
|
|
|
|
sink.add()
|
|
|
|
})
|
2010-12-14 07:21:40 +08:00
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2011-11-22 11:42:43 +08:00
|
|
|
module.exports = helper;
|
2010-12-14 07:21:40 +08:00
|
|
|
|