Skip to content

Commit 11aaf68

Browse files
committed
Add basic unit test
1 parent ba6abd4 commit 11aaf68

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

packages/pg/test/unit/client/simple-query-tests.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,38 @@ test('executing query', function () {
6060
})
6161
})
6262

63+
test("multiple in the queue, pipelining mode", function () {
64+
var client = helper.client()
65+
client.pipelining = true
66+
var connection = client.connection
67+
var queries = connection.queries
68+
client.query('one')
69+
client.query('two')
70+
client.query('three')
71+
assert.empty(queries)
72+
73+
test("after one ready for query", function () {
74+
connection.emit('readyForQuery')
75+
assert.lengthIs(queries, 3)
76+
assert.equal(queries[0], "one")
77+
})
78+
79+
test('after two ready for query', function () {
80+
connection.emit('readyForQuery')
81+
assert.lengthIs(queries, 3)
82+
})
83+
84+
test("after a bunch more", function () {
85+
connection.emit('readyForQuery')
86+
connection.emit('readyForQuery')
87+
connection.emit('readyForQuery')
88+
assert.lengthIs(queries, 3)
89+
assert.equal(queries[0], "one")
90+
assert.equal(queries[1], 'two')
91+
assert.equal(queries[2], 'three')
92+
})
93+
})
94+
6395
test('query event binding and flow', function () {
6496
var client = helper.client()
6597
var con = client.connection

0 commit comments

Comments
 (0)