-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathbound-command-tests.js
58 lines (50 loc) · 1.31 KB
/
bound-command-tests.js
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
53
54
55
56
57
58
'use strict'
var helper = require(__dirname + '/test-helper')
// http://developer.postgresql.org/pgdocs/postgres/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY
test('flushing once', function () {
helper.connect(function (con) {
con.parse({
text: 'select * from ids'
})
con.bind()
con.execute()
con.flush()
assert.emits(con, 'parseComplete')
assert.emits(con, 'bindComplete')
assert.emits(con, 'dataRow')
assert.emits(con, 'commandComplete', function () {
con.sync()
})
assert.emits(con, 'readyForQuery', function () {
con.end()
})
})
})
test('sending many flushes', function () {
helper.connect(function (con) {
assert.emits(con, 'parseComplete', function () {
con.bind()
con.flush()
})
assert.emits(con, 'bindComplete', function () {
con.execute()
con.flush()
})
assert.emits(con, 'dataRow', function (msg) {
assert.equal(msg.fields[0], 1)
assert.emits(con, 'dataRow', function (msg) {
assert.equal(msg.fields[0], 2)
assert.emits(con, 'commandComplete', function () {
con.sync()
})
assert.emits(con, 'readyForQuery', function () {
con.end()
})
})
})
con.parse({
text: 'select * from ids order by id'
})
con.flush()
})
})