forked from brianc/node-postgres
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery-queue-tests.js
More file actions
52 lines (45 loc) · 1.23 KB
/
query-queue-tests.js
File metadata and controls
52 lines (45 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var helper = require(__dirname + '/test-helper');
var Connection = require(__dirname + '/../../../lib/connection');
test('drain', function() {
var con = new Connection({stream: "NO"});
var client = new Client({connection:con});
con.connect = function() {
con.emit('connect');
};
con.query = function() {
};
client.connect();
var raisedDrain = false;
client.on('drain', function() {
raisedDrain = true;
});
client.query("hello");
client.query("sup");
client.query('boom');
test("with pending queries", function() {
test("does not emit drain", function() {
assert.equal(raisedDrain, false);
});
});
test("after some queries executed", function() {
con.emit('readyForQuery');
test("does not emit drain", function() {
assert.equal(raisedDrain, false);
});
});
test("when all queries are sent", function() {
con.emit('readyForQuery');
con.emit('readyForQuery');
test("does not emit drain", function() {
assert.equal(raisedDrain, false);
});
});
test("after last query finishes", function() {
con.emit('readyForQuery');
test("emits drain", function() {
process.nextTick(function() {
assert.ok(raisedDrain);
})
});
});
});