mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
@@ -26,6 +26,7 @@ var flowUtils = NR_TEST_UTILS.require("@node-red/runtime/lib/flows/util");
|
||||
var Flow = NR_TEST_UTILS.require("@node-red/runtime/lib/flows/Flow");
|
||||
var flows = NR_TEST_UTILS.require("@node-red/runtime/lib/flows");
|
||||
var Node = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/Node");
|
||||
var credentials = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/credentials");
|
||||
var hooks = NR_TEST_UTILS.require("@node-red/util/lib/hooks");
|
||||
var typeRegistry = NR_TEST_UTILS.require("@node-red/registry");
|
||||
|
||||
@@ -61,6 +62,7 @@ describe('Flow', function() {
|
||||
this.scope = n.scope;
|
||||
var node = this;
|
||||
this.foo = n.foo;
|
||||
this.bar = n.bar;
|
||||
this.handled = 0;
|
||||
this.stopped = false;
|
||||
currentNodes[node.id] = node;
|
||||
@@ -1372,13 +1374,24 @@ describe('Flow', function() {
|
||||
it("global flow can access global-config defined environment variables", async function () {
|
||||
after(function() {
|
||||
delete process.env.V0;
|
||||
credentials.get.restore()
|
||||
})
|
||||
|
||||
sinon.stub(credentials,"get").callsFake(function(id) {
|
||||
if (id === 'gc') {
|
||||
return { map: { GC_CRED: 'gc_cred' }}
|
||||
}
|
||||
return null
|
||||
})
|
||||
|
||||
const config = flowUtils.parseConfig([
|
||||
{id:"gc", type:"global-config", env:[
|
||||
{"name": "GC0", value: "3+4", type: "jsonata"}
|
||||
{"name": "GC0", value: "3+4", type: "jsonata"},
|
||||
{"name": "GC_CRED", type: "cred"},
|
||||
|
||||
]},
|
||||
{id:"t1",type:"tab" },
|
||||
{id:"1",x:10,y:10,z:"t1",type:"test",foo:"${GC0}",wires:[]},
|
||||
{id:"1",x:10,y:10,z:"t1",type:"test",foo:"${GC0}", bar:"${GC_CRED}", wires:[]},
|
||||
]);
|
||||
// Two-arg call - makes this the global flow that handles global-config nodes
|
||||
const globalFlow = Flow.create({getSetting:v=>process.env[v]},config);
|
||||
@@ -1390,6 +1403,7 @@ describe('Flow', function() {
|
||||
|
||||
var activeNodes = flow.getActiveNodes();
|
||||
activeNodes["1"].foo.should.equal(7);
|
||||
activeNodes["1"].bar.should.equal('gc_cred');
|
||||
|
||||
await flow.stop()
|
||||
await globalFlow.stop()
|
||||
|
Reference in New Issue
Block a user