Skip to content

Commit ba1e354

Browse files
antonbrianc
anton
authored andcommitted
test connection and backend event exchange during COPY TO/FROM
1 parent 8bcd405 commit ba1e354

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
var helper = require(__dirname+"/test-helper");
2+
var assert = require('assert');
3+
4+
test('COPY FROM events check', function () {
5+
helper.connect(function (con) {
6+
var stdinStream = con.query('COPY person FROM STDIN');
7+
con.on('copyInResponse', function () {
8+
con.endCopyFrom();
9+
});
10+
assert.emits(con, 'copyInResponse',
11+
function () {
12+
con.endCopyFrom();
13+
},
14+
"backend should emit copyInResponse after COPY FROM query"
15+
);
16+
assert.emits(con, 'commandComplete',
17+
function () {
18+
con.end();
19+
},
20+
"backend should emit commandComplete after COPY FROM stream ends"
21+
)
22+
});
23+
});
24+
test('COPY TO events check', function () {
25+
helper.connect(function (con) {
26+
var stdoutStream = con.query('COPY person TO STDOUT');
27+
assert.emits(con, 'copyOutResponse',
28+
function () {
29+
},
30+
"backend should emit copyOutResponse after COPY TO query"
31+
);
32+
assert.emits(con, 'copyData',
33+
function () {
34+
},
35+
"backend should emit copyData on every data row"
36+
);
37+
assert.emits(con, 'copyDone',
38+
function () {
39+
con.end();
40+
},
41+
"backend should emit copyDone after all data rows"
42+
);
43+
});
44+
});

0 commit comments

Comments
 (0)