From ba1e3546f1ce889a3552348ccaf98389dcc87485 Mon Sep 17 00:00:00 2001 From: anton Date: Sun, 23 Dec 2012 13:46:31 +0200 Subject: [PATCH] test connection and backend event exchange during COPY TO/FROM --- test/integration/connection/copy-tests.js | 44 +++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 test/integration/connection/copy-tests.js diff --git a/test/integration/connection/copy-tests.js b/test/integration/connection/copy-tests.js new file mode 100644 index 00000000..ee4a71c5 --- /dev/null +++ b/test/integration/connection/copy-tests.js @@ -0,0 +1,44 @@ +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" + ); + }); +});