mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
parent
c05e9da9c5
commit
f62cf6818b
@ -38,7 +38,7 @@ function getContext(localId,flowId) {
|
|||||||
if (flowId) {
|
if (flowId) {
|
||||||
contextId = localId+":"+flowId;
|
contextId = localId+":"+flowId;
|
||||||
}
|
}
|
||||||
if (contexts[contextId]) {
|
if (contexts.hasOwnProperty(contextId)) {
|
||||||
return contexts[contextId];
|
return contexts[contextId];
|
||||||
}
|
}
|
||||||
var newContext = createContext(contextId);
|
var newContext = createContext(contextId);
|
||||||
@ -65,7 +65,7 @@ function clean(flowConfig) {
|
|||||||
for (var id in contexts) {
|
for (var id in contexts) {
|
||||||
if (contexts.hasOwnProperty(id)) {
|
if (contexts.hasOwnProperty(id)) {
|
||||||
var idParts = id.split(":");
|
var idParts = id.split(":");
|
||||||
if (!flowConfig.allNodes[idParts[0]]) {
|
if (!flowConfig.allNodes.hasOwnProperty(idParts[0])) {
|
||||||
delete contexts[id];
|
delete contexts[id];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ var flows = require("../../red/runtime/nodes/flows");
|
|||||||
var credentials = require("../../red/runtime/nodes/credentials");
|
var credentials = require("../../red/runtime/nodes/credentials");
|
||||||
var comms = require("../../red/api/comms.js");
|
var comms = require("../../red/api/comms.js");
|
||||||
var log = require("../../red/runtime/log.js");
|
var log = require("../../red/runtime/log.js");
|
||||||
|
var context = require("../../red/runtime/nodes/context.js");
|
||||||
|
|
||||||
var http = require('http');
|
var http = require('http');
|
||||||
var express = require('express');
|
var express = require('express');
|
||||||
@ -53,6 +54,8 @@ function helperNode(n) {
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
load: function(testNode, testFlows, testCredentials, cb) {
|
load: function(testNode, testFlows, testCredentials, cb) {
|
||||||
|
var i;
|
||||||
|
|
||||||
logSpy = sinon.spy(log,"log");
|
logSpy = sinon.spy(log,"log");
|
||||||
logSpy.FATAL = log.FATAL;
|
logSpy.FATAL = log.FATAL;
|
||||||
logSpy.ERROR = log.ERROR;
|
logSpy.ERROR = log.ERROR;
|
||||||
@ -88,7 +91,7 @@ module.exports = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var red = {};
|
var red = {};
|
||||||
for (var i in RED) {
|
for (i in RED) {
|
||||||
if (RED.hasOwnProperty(i) && !/^(init|start|stop)$/.test(i)) {
|
if (RED.hasOwnProperty(i) && !/^(init|start|stop)$/.test(i)) {
|
||||||
var propDescriptor = Object.getOwnPropertyDescriptor(RED,i);
|
var propDescriptor = Object.getOwnPropertyDescriptor(RED,i);
|
||||||
Object.defineProperty(red,i,propDescriptor);
|
Object.defineProperty(red,i,propDescriptor);
|
||||||
@ -103,7 +106,7 @@ module.exports = {
|
|||||||
credentials.init(storage,express());
|
credentials.init(storage,express());
|
||||||
RED.nodes.registerType("helper", helperNode);
|
RED.nodes.registerType("helper", helperNode);
|
||||||
if (Array.isArray(testNode)) {
|
if (Array.isArray(testNode)) {
|
||||||
for (var i = 0; i < testNode.length; i++) {
|
for (i = 0; i < testNode.length; i++) {
|
||||||
testNode[i](red);
|
testNode[i](red);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -120,6 +123,7 @@ module.exports = {
|
|||||||
// TODO: any other state to remove between tests?
|
// TODO: any other state to remove between tests?
|
||||||
redNodes.clearRegistry();
|
redNodes.clearRegistry();
|
||||||
logSpy.restore();
|
logSpy.restore();
|
||||||
|
context.clean({allNodes:[]});
|
||||||
return flows.stopFlows();
|
return flows.stopFlows();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user