Exec node: remove addpayValue and reuse addpay to track appending property

This commit is contained in:
Nick O'Leary
2021-03-31 23:50:00 +01:00
parent 89485971fa
commit bdb548ffdc
3 changed files with 29 additions and 14 deletions

View File

@@ -41,7 +41,7 @@ describe('exec node', function() {
n1.should.have.property("name", "exec1");
n1.should.have.property("cmd", "");
n1.should.have.property("append", "");
n1.should.have.property("addpay",true);
n1.should.have.property("addpay","payload");
n1.should.have.property("timer",0);
n1.should.have.property("oldrc","false");
done();
@@ -115,23 +115,27 @@ describe('exec node', function() {
});
it('should exec a simple command with appended value from message', function (done) {
var flow = [{id:"n1", type:"exec", wires:[["n2"]], command:"echo", addpay:true, addpayValue:"topic", append:"more", oldrc:"false"},
var flow = [{id:"n1", type:"exec", wires:[["n2"]], command:"echo", addpay:"topic", append:"more", oldrc:"false"},
{id:"n2", type:"helper"}];
helper.load(execNode, flow, function () {
var n1 = helper.getNode("n1");
var n2 = helper.getNode("n2");
n2.on("input", function (msg) {
try {
msg.should.have.property("payload");
msg.payload.should.be.a.String();
msg.payload.should.equal("bar more\n");
done();
} catch(err) {
done(err)
}
});
n1.receive({payload:"foo", topic:"bar"});
});
});
it('should exec a simple command with extra parameters', function(done) {
var flow = [{id:"n1",type:"exec",wires:[["n2"],["n3"],["n4"]],command:"echo", addpay:true, append:"more", oldrc:"false"},
var flow = [{id:"n1",type:"exec",wires:[["n2"],["n3"],["n4"]],command:"echo", addpay:"payload", append:"more", oldrc:"false"},
{id:"n2", type:"helper"},{id:"n3", type:"helper"},{id:"n4", type:"helper"}];
var spy = sinon.stub(child_process, 'exec',
function(arg1, arg2, arg3, arg4) {