Test interspersed messages emit a warning event

This commit is contained in:
Rafa de la Torre 2019-06-04 15:41:59 +02:00
parent 0c787920a4
commit 645616c2e0

View File

@ -151,6 +151,24 @@ var testInterspersedMessageDoesNotBreakCopyFlow = function() {
}; };
testInterspersedMessageDoesNotBreakCopyFlow(); testInterspersedMessageDoesNotBreakCopyFlow();
var testInterspersedMessageEmitsWarnign = function() {
var toClient = client();
toClient.query(warnAndReturnOne, (err, res) => {
var q = "COPY (SELECT * FROM pg_temp.test_warn_return_one()) TO STDOUT WITH (FORMAT 'csv', HEADER true)";
var stream = toClient.query(copy(q));
var done = gonna('got expected warning event', 1000, function() {
toClient.end();
});
stream.on('warning', function(msg) {
assert(msg.match(/Got an interspersed message:.*WARNING.*hey, this is returning one/),
'did not get expected warning for interspersed message in COPY TO');
done();
})
});
};
testInterspersedMessageEmitsWarnign();
var testClientReuse = function() { var testClientReuse = function() {
var c = client(); var c = client();
var limit = 100000; var limit = 100000;