2010-12-14 07:21:40 +08:00
|
|
|
var helper = require(__dirname + "/../test-helper");
|
|
|
|
var pg = require(__dirname + "/../../../lib");
|
|
|
|
helper.pg = pg;
|
|
|
|
|
|
|
|
var testPoolSize = function(max) {
|
|
|
|
var conString = helper.connectionString();
|
|
|
|
var sink = new helper.Sink(max, function() {
|
|
|
|
helper.pg.end(conString);
|
|
|
|
});
|
|
|
|
|
|
|
|
test("can pool " + max + " times", function() {
|
|
|
|
for(var i = 0; i < max; i++) {
|
|
|
|
helper.pg.poolSize = 10;
|
|
|
|
helper.pg.connect(conString, function(err, client) {
|
|
|
|
assert.isNull(err);
|
|
|
|
client.query("select * from NOW()", function() {
|
|
|
|
sink.add();
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2010-12-11 07:32:34 +08:00
|
|
|
module.exports = {
|
2010-12-14 07:21:40 +08:00
|
|
|
args: helper.args,
|
|
|
|
pg: helper.pg,
|
|
|
|
connectionString: helper.connectionString,
|
|
|
|
Sink: helper.Sink,
|
|
|
|
testPoolSize: testPoolSize
|
2010-12-11 07:32:34 +08:00
|
|
|
}
|
2010-12-14 07:21:40 +08:00
|
|
|
|