-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathcopy-tests.js
45 lines (44 loc) · 1.17 KB
/
copy-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
'use strict'
var helper = require(__dirname + '/test-helper')
var assert = require('assert')
test('COPY FROM events check', function () {
helper.connect(function (con) {
var stdinStream = con.query('COPY person FROM STDIN')
con.on('copyInResponse', function () {
con.endCopyFrom()
})
assert.emits(con, 'copyInResponse',
function () {
con.endCopyFrom()
},
'backend should emit copyInResponse after COPY FROM query'
)
assert.emits(con, 'commandComplete',
function () {
con.end()
},
'backend should emit commandComplete after COPY FROM stream ends'
)
})
})
test('COPY TO events check', function () {
helper.connect(function (con) {
var stdoutStream = con.query('COPY person TO STDOUT')
assert.emits(con, 'copyOutResponse',
function () {
},
'backend should emit copyOutResponse after COPY TO query'
)
assert.emits(con, 'copyData',
function () {
},
'backend should emit copyData on every data row'
)
assert.emits(con, 'copyDone',
function () {
con.end()
},
'backend should emit copyDone after all data rows'
)
})
})