Skip to content

Commit c75c6e3

Browse files
committed
fix failing test on 9.0 due to the 'instant' nature of notification messages
1 parent ddd189b commit c75c6e3

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

test/integration/client/notice-tests.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,25 @@ test('emits notify message', function() {
1616
client.query('LISTEN boom', assert.calls(function() {
1717
var otherClient = helper.client();
1818
otherClient.query('LISTEN boom', assert.calls(function() {
19-
var afterNotify = function() {
20-
assert.emits(client, 'notification', function(msg) {
19+
assert.emits(client, 'notification', function(msg) {
20+
//make sure PQfreemem doesn't invalidate string pointers
21+
setTimeout(function() {
22+
assert.equal(msg.channel, 'boom');
23+
assert.ok(msg.payload == 'omg!' /*9.x*/ || msg.payload == '' /*8.x*/, "expected blank payload or correct payload but got " + msg.message)
24+
client.end()
25+
}, 500)
2126

22-
//make sure PQfreemem doesn't invalidate string pointers
23-
setTimeout(function() {
24-
assert.equal(msg.channel, 'boom');
25-
assert.ok(msg.payload == 'omg!' /*9.x*/ || msg.payload == '' /*8.x*/, "expected blank payload or correct payload but got " + msg.message)
26-
client.end()
27-
}, 500)
27+
});
28+
assert.emits(otherClient, 'notification', function(msg) {
29+
assert.equal(msg.channel, 'boom');
30+
otherClient.end();
31+
});
2832

29-
});
30-
assert.emits(otherClient, 'notification', function(msg) {
31-
assert.equal(msg.channel, 'boom');
32-
otherClient.end();
33-
});
34-
}
3533
client.query("NOTIFY boom, 'omg!'", function(err, q) {
3634
if(err) {
3735
//notify not supported with payload on 8.x
3836
client.query("NOTIFY boom")
39-
}
40-
afterNotify();
37+
}
4138
});
4239
}));
4340
}));

0 commit comments

Comments
 (0)