From 965b7b4f8487d56a8ff05d9fb29ddf0a25e16b34 Mon Sep 17 00:00:00 2001 From: anton Date: Sun, 23 Dec 2012 14:44:31 +0200 Subject: [PATCH] test event exchange between libpq bindings and js while COPY TO/FROM --- test/native/copy-events-tests.js | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/native/copy-events-tests.js diff --git a/test/native/copy-events-tests.js b/test/native/copy-events-tests.js new file mode 100644 index 0000000..0633b56 --- /dev/null +++ b/test/native/copy-events-tests.js @@ -0,0 +1,36 @@ +var helper = require(__dirname+"/../test-helper"); +var Client = require(__dirname + "/../../lib/native"); +test('COPY FROM events check', function () { + var con = new Client(helper.config), + stdinStream = con.copyFrom('COPY person FROM STDIN'); + assert.emits(con, 'copyInResponse', + function () { + stdinStream.end(); + }, + "backend should emit copyInResponse after COPY FROM query" + ); + assert.emits(con, '_readyForQuery', + function () { + con.end(); + }, + "backend should emit _readyForQuery after data will be coped to stdin stream" + ); + con.connect(); +}); +test('COPY TO events check', function () { + var con = new Client(helper.config), + stdoutStream = con.copyTo('COPY person TO STDOUT'); + assert.emits(con, 'copyData', + function () { + }, + "backend should emit copyData on every data row" + ); + assert.emits(con, '_readyForQuery', + function () { + con.end(); + }, + "backend should emit _readyForQuery after data will be coped to stdout stream" + ); + con.connect(); +}); +