From 6252b075bc174825f0c964f02aa97ecc07fa7c2f Mon Sep 17 00:00:00 2001 From: Hiroyasu Nishiyama Date: Tue, 13 Feb 2018 20:55:03 +0900 Subject: [PATCH] fixed message modificcation of concat mode of BATCH node --- nodes/core/logic/19-batch.js | 2 +- test/nodes/core/logic/19-batch_spec.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/nodes/core/logic/19-batch.js b/nodes/core/logic/19-batch.js index 37f20d2aa..495862af8 100644 --- a/nodes/core/logic/19-batch.js +++ b/nodes/core/logic/19-batch.js @@ -116,7 +116,7 @@ module.exports = function(RED) { for (var topic of topics) { remove_topic(pending, topic); } - send_msgs(node, msgs, false); + send_msgs(node, msgs, true); node.pending_count -= msgs.length; } diff --git a/test/nodes/core/logic/19-batch_spec.js b/test/nodes/core/logic/19-batch_spec.js index f08abaef4..5593c5c97 100644 --- a/test/nodes/core/logic/19-batch_spec.js +++ b/test/nodes/core/logic/19-batch_spec.js @@ -54,8 +54,13 @@ describe('BATCH node', function() { var ix0 = 0; // seq no var ix1 = 0; // loc. in seq var seq = undefined; + var msgs = []; n2.on("input", function(msg) { try { + for (var i = 0; i < msgs.length; i++) { + msg.should.not.equal(msgs[i]); + } + msgs.push(msg); if (seq === undefined) { seq = results[ix0]; } @@ -306,6 +311,19 @@ describe('BATCH node', function() { check_concat(flow, results, inputs, done); }); + it('should concat same seq.', function(done) { + var flow = [{id:"n1", type:"batch", name: "BatchNode", mode: "concat", count: 0, overlap: 0, interval: 1, allowEmptySequence: false, topics: [{topic: "TA"}, {topic: "TA"}], wires:[["n2"]]}, + {id:"n2", type:"helper"}]; + var results = [ + [9, 8, 9, 8] + ]; + var inputs = [ + ["TA", 9, 0, 2], + ["TA", 8, 1, 2] + ]; + check_concat(flow, results, inputs, done); + }); + it('should handle too many pending messages', function(done) { var flow = [{id:"n1", type:"batch", name: "BatchNode", mode: "concat", count: 0, overlap: 0, interval: 1, allowEmptySequence: false, topics: [{topic: "TA"}, {topic: "TB"}], wires:[["n2"]]}, {id:"n2", type:"helper"}];