mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
fix env var access using $env for groups
This commit is contained in:
@@ -1275,6 +1275,52 @@ describe('Flow', function() {
|
||||
}
|
||||
|
||||
});
|
||||
it("can access environment variable property using $parent", function (done) {
|
||||
try {
|
||||
after(function() {
|
||||
delete process.env.V0;
|
||||
delete process.env.V1;
|
||||
})
|
||||
process.env.V0 = "gv0";
|
||||
process.env.V1 = "gv1";
|
||||
var config = flowUtils.parseConfig([
|
||||
{id:"t1",type:"tab",env:[
|
||||
{"name": "V0", value: "v0", type: "str"}
|
||||
]},
|
||||
{id:"g1",type:"group",z:"t1",env:[
|
||||
{"name": "V0", value: "v1", type: "str"},
|
||||
{"name": "V1", value: "v2", type: "str"}
|
||||
]},
|
||||
{id:"g2",type:"group",z:"t1",g:"g1",env:[
|
||||
{"name": "V1", value: "v3", type: "str"}
|
||||
]},
|
||||
{id:"1",x:10,y:10,z:"t1",type:"test",foo:"${$parent.V0}",wires:[]},
|
||||
{id:"2",x:10,y:10,z:"t1",g:"g1",type:"test",foo:"${$parent.V0}",wires:[]},
|
||||
{id:"3",x:10,y:10,z:"t1",g:"g1",type:"test",foo:"${$parent.V1}",wires:[]},
|
||||
{id:"4",x:10,y:10,z:"t1",g:"g2",type:"test",foo:"${$parent.V1}",wires:[]},
|
||||
{id:"5",x:10,y:10,z:"t1",type:"test",foo:"${$parent.V1}",wires:[]},
|
||||
]);
|
||||
var flow = Flow.create({getSetting:v=>process.env[v]},config,config.flows["t1"]);
|
||||
flow.start();
|
||||
|
||||
var activeNodes = flow.getActiveNodes();
|
||||
|
||||
activeNodes["1"].foo.should.equal("gv0");
|
||||
activeNodes["2"].foo.should.equal("v0");
|
||||
activeNodes["3"].foo.should.equal("gv1");
|
||||
activeNodes["4"].foo.should.equal("v2");
|
||||
activeNodes["5"].foo.should.equal("gv1");
|
||||
|
||||
flow.stop().then(function() {
|
||||
done();
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
console.log(e.stack);
|
||||
done(e);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user