diff --git a/test/integration/client/api-tests.js b/test/integration/client/api-tests.js index bdffbee5..428b1b71 100644 --- a/test/integration/client/api-tests.js +++ b/test/integration/client/api-tests.js @@ -6,7 +6,7 @@ var log = function() { //console.log.apply(console, arguments); } -var sink = new helper.Sink(4, 10000, function() { +var sink = new helper.Sink(5, 10000, function() { log("ending connection pool: %s", connectionString); pg.end(connectionString); }); @@ -92,3 +92,19 @@ test("query errors are handled and do not bubble if callback is provded", functi })) })) }) + +test('callback is fired once and only once', function() { + pg.connect(connectionString, assert.calls(function(err, client) { + assert.isNull(err); + client.query("CREATE TEMP TABLE boom(name varchar(10))"); + var callCount = 0; + client.query([ + "INSERT INTO boom(name) VALUES('hai')", + "INSERT INTO boom(name) VALUES('boom')", + "INSERT INTO boom(name) VALUES('zoom')", + ].join(";"), function(err, callback) { + assert.equal(callCount++, 0, "Call count should be 0. More means this callback fired more than once."); + sink.add(); + }) + })) +})