Skip to content

Commit 965b7b4

Browse files
antonbrianc
anton
authored andcommitted
test event exchange between libpq bindings and js while COPY TO/FROM
1 parent ba1e354 commit 965b7b4

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/native/copy-events-tests.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
var helper = require(__dirname+"/../test-helper");
2+
var Client = require(__dirname + "/../../lib/native");
3+
test('COPY FROM events check', function () {
4+
var con = new Client(helper.config),
5+
stdinStream = con.copyFrom('COPY person FROM STDIN');
6+
assert.emits(con, 'copyInResponse',
7+
function () {
8+
stdinStream.end();
9+
},
10+
"backend should emit copyInResponse after COPY FROM query"
11+
);
12+
assert.emits(con, '_readyForQuery',
13+
function () {
14+
con.end();
15+
},
16+
"backend should emit _readyForQuery after data will be coped to stdin stream"
17+
);
18+
con.connect();
19+
});
20+
test('COPY TO events check', function () {
21+
var con = new Client(helper.config),
22+
stdoutStream = con.copyTo('COPY person TO STDOUT');
23+
assert.emits(con, 'copyData',
24+
function () {
25+
},
26+
"backend should emit copyData on every data row"
27+
);
28+
assert.emits(con, '_readyForQuery',
29+
function () {
30+
con.end();
31+
},
32+
"backend should emit _readyForQuery after data will be coped to stdout stream"
33+
);
34+
con.connect();
35+
});
36+

0 commit comments

Comments
 (0)