Skip to content

Commit 28bbbf9

Browse files
committed
modified connection info for invalid connection test to use localhost
in order to avoid long timeouts in dns
1 parent 509564f commit 28bbbf9

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

test/integration/client/api-tests.js

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@ var helper = require(__dirname + '/../test-helper');
22
var pg = require(__dirname + '/../../../lib');
33
var connectionString = helper.connectionString(__filename);
44

5+
var log = function() {
6+
//console.log.apply(console, arguments);
7+
}
58

6-
var sink = new helper.Sink(2, function() {
9+
var sink = new helper.Sink(4, 10000, function() {
10+
log("ending connection pool: %s", connectionString);
711
pg.end(connectionString);
812
});
913

1014
test('api', function() {
15+
log("connecting to %s", connectionString)
1116
pg.connect(connectionString, assert.calls(function(err, client) {
1217
assert.equal(err, null, "Failed to connect: " + sys.inspect(err));
1318

@@ -19,20 +24,26 @@ test('api', function() {
1924

2025

2126
test('simple query execution',assert.calls( function() {
22-
client.query("SELECT * FROM band WHERE name = 'the beach boys'", function(err, result) {
27+
log("executing simple query")
28+
client.query("SELECT * FROM band WHERE name = 'the beach boys'", assert.calls(function(err, result) {
2329
assert.length(result.rows, 1)
2430
assert.equal(result.rows.pop().name, 'the beach boys')
25-
});
31+
log("simple query executed")
32+
}));
2633

2734
}))
2835

2936
test('prepared statement execution',assert.calls( function() {
37+
log("executing prepared statement 1")
3038
client.query('SELECT * FROM band WHERE name = $1', ['dead black hearts'],assert.calls( function(err, result) {
39+
log("Prepared statement 1 finished")
3140
assert.length(result.rows, 1);
3241
assert.equal(result.rows.pop().name, 'dead black hearts');
3342
}))
3443

44+
log("executing prepared statement two")
3545
client.query('SELECT * FROM band WHERE name LIKE $1 ORDER BY name', ['the %'], assert.calls(function(err, result) {
46+
log("prepared statement two finished")
3647
assert.length(result.rows, 2);
3748
assert.equal(result.rows.pop().name, 'the flaming lips');
3849
assert.equal(result.rows.pop().name, 'the beach boys');
@@ -46,10 +57,12 @@ test('api', function() {
4657
test('executing nested queries', function() {
4758
pg.connect(connectionString, assert.calls(function(err, client) {
4859
assert.isNull(err);
60+
log("connected for nested queriese")
4961
client.query('select now as now from NOW()', assert.calls(function(err, result) {
5062
assert.equal(new Date().getYear(), result.rows[0].now.getYear())
5163
client.query('select now as now_again FROM NOW()', assert.calls(function() {
5264
client.query('select * FROM NOW()', assert.calls(function() {
65+
log('all nested queries recieved')
5366
assert.ok('all queries hit')
5467
sink.add();
5568
}))
@@ -59,17 +72,23 @@ test('executing nested queries', function() {
5972
})
6073

6174
test('raises error if cannot connect', function() {
62-
var connectionString = "pg://asdf@seoiasfd:4884/ieieie";
75+
var connectionString = "pg://sfalsdkf:asdf@localhost/ieieie";
76+
log("trying to connect to invalid place for error")
6377
pg.connect(connectionString, assert.calls(function(err, client) {
6478
assert.ok(err, 'should have raised an error')
79+
log("invalid connection supplied error to callback")
80+
sink.add();
6581
}))
6682
})
6783

68-
test("query errors are handled and do not bubble if callbac is provded", function() {
84+
test("query errors are handled and do not bubble if callback is provded", function() {
6985
pg.connect(connectionString, assert.calls(function(err, client) {
7086
assert.isNull(err)
87+
log("checking for query error")
7188
client.query("SELECT OISDJF FROM LEIWLISEJLSE", assert.calls(function(err, result) {
7289
assert.ok(err);
73-
}))
90+
log("query error supplied error to callback")
91+
sink.add();
92+
}))
7493
}))
7594
})

0 commit comments

Comments
 (0)