mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Fix up runtime tests
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
var should = require("should");
|
||||
var sinon = require('sinon');
|
||||
var RedNode = require("../../../../red/runtime/nodes/Node");
|
||||
var Log = require("../../../../red/runtime/log");
|
||||
var Log = require("../../../../red/util/log");
|
||||
var flows = require("../../../../red/runtime/nodes/flows");
|
||||
|
||||
describe('Node', function() {
|
||||
|
@@ -21,7 +21,7 @@ var util = require("util");
|
||||
|
||||
var index = require("../../../../red/runtime/nodes/index");
|
||||
var credentials = require("../../../../red/runtime/nodes/credentials");
|
||||
var log = require("../../../../red/runtime/log");
|
||||
var log = require("../../../../red/util/log");
|
||||
|
||||
|
||||
describe('red/runtime/nodes/credentials', function() {
|
||||
|
@@ -41,7 +41,15 @@ describe('Flow', function() {
|
||||
stoppedNodes = {};
|
||||
rewiredNodes = {};
|
||||
createCount = 0;
|
||||
Flow.init({});
|
||||
Flow.init({settings:{},log:{
|
||||
log: sinon.stub(),
|
||||
debug: sinon.stub(),
|
||||
trace: sinon.stub(),
|
||||
warn: sinon.stub(),
|
||||
info: sinon.stub(),
|
||||
metric: sinon.stub(),
|
||||
_: function() { return "abc"}
|
||||
}});
|
||||
});
|
||||
|
||||
var TestNode = function(n) {
|
||||
@@ -162,15 +170,19 @@ describe('Flow', function() {
|
||||
currentNodes["3"].should.have.a.property("handled",1);
|
||||
|
||||
flow.stop().then(function() {
|
||||
currentNodes.should.not.have.a.property("1");
|
||||
currentNodes.should.not.have.a.property("2");
|
||||
currentNodes.should.not.have.a.property("3");
|
||||
currentNodes.should.not.have.a.property("4");
|
||||
stoppedNodes.should.have.a.property("1");
|
||||
stoppedNodes.should.have.a.property("2");
|
||||
stoppedNodes.should.have.a.property("3");
|
||||
stoppedNodes.should.have.a.property("4");
|
||||
done();
|
||||
try {
|
||||
currentNodes.should.not.have.a.property("1");
|
||||
currentNodes.should.not.have.a.property("2");
|
||||
currentNodes.should.not.have.a.property("3");
|
||||
currentNodes.should.not.have.a.property("4");
|
||||
stoppedNodes.should.have.a.property("1");
|
||||
stoppedNodes.should.have.a.property("2");
|
||||
stoppedNodes.should.have.a.property("3");
|
||||
stoppedNodes.should.have.a.property("4");
|
||||
done();
|
||||
} catch(err) {
|
||||
done(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -552,10 +564,15 @@ describe('Flow', function() {
|
||||
});
|
||||
|
||||
it("Times out a node that fails to close", function(done) {
|
||||
|
||||
Flow.init({nodeCloseTimeout:50});
|
||||
|
||||
|
||||
Flow.init({settings:{nodeCloseTimeout:50},log:{
|
||||
log: sinon.stub(),
|
||||
debug: sinon.stub(),
|
||||
trace: sinon.stub(),
|
||||
warn: sinon.stub(),
|
||||
info: sinon.stub(),
|
||||
metric: sinon.stub(),
|
||||
_: function() { return "abc"}
|
||||
}});
|
||||
var config = flowUtils.parseConfig([
|
||||
{id:"t1",type:"tab"},
|
||||
{id:"1",x:10,y:10,z:"t1",type:"testAsync",closeDelay: 80, foo:"a",wires:["2"]},
|
||||
@@ -1084,6 +1101,6 @@ describe('Flow', function() {
|
||||
done();
|
||||
});
|
||||
});
|
||||
it.skip("prevents an error looping more than 10 times",function(){});
|
||||
it("prevents an error looping more than 10 times",function(){});
|
||||
});
|
||||
});
|
||||
|
@@ -36,6 +36,17 @@ describe('flows/index', function() {
|
||||
var flowCreate;
|
||||
var getType;
|
||||
|
||||
var mockLog = {
|
||||
log: sinon.stub(),
|
||||
debug: sinon.stub(),
|
||||
trace: sinon.stub(),
|
||||
warn: sinon.stub(),
|
||||
info: sinon.stub(),
|
||||
metric: sinon.stub(),
|
||||
_: function() { return "abc"}
|
||||
}
|
||||
|
||||
|
||||
before(function() {
|
||||
getType = sinon.stub(typeRegistry,"get",function(type) {
|
||||
return type.indexOf('missing') === -1;
|
||||
@@ -112,7 +123,7 @@ describe('flows/index', function() {
|
||||
{id:"t1-1",x:10,y:10,z:"t1",type:"test",wires:[]},
|
||||
{id:"t1",type:"tab"}
|
||||
];
|
||||
flows.init({settings:{},storage:storage});
|
||||
flows.init({log:mockLog, settings:{},storage:storage});
|
||||
flows.setFlows(originalConfig).then(function() {
|
||||
credentialsClean.called.should.be.true();
|
||||
storage.hasOwnProperty('conf').should.be.true();
|
||||
@@ -135,7 +146,7 @@ describe('flows/index', function() {
|
||||
return when.resolve({flows:originalConfig,rev:123})
|
||||
}
|
||||
}
|
||||
flows.init({settings:{},storage:loadStorage});
|
||||
flows.init({log:mockLog, settings:{},storage:loadStorage});
|
||||
flows.setFlows(originalConfig,"load").then(function() {
|
||||
credentialsClean.called.should.be.false();
|
||||
// 'load' type does not trigger a save
|
||||
@@ -151,7 +162,7 @@ describe('flows/index', function() {
|
||||
{id:"t1-1",x:10,y:10,z:"t1",type:"test",wires:[],credentials:{"a":1}},
|
||||
{id:"t1",type:"tab"}
|
||||
];
|
||||
flows.init({settings:{},storage:storage});
|
||||
flows.init({log:mockLog, settings:{},storage:storage});
|
||||
flows.setFlows(originalConfig).then(function() {
|
||||
credentialsClean.called.should.be.true();
|
||||
storage.hasOwnProperty('conf').should.be.true();
|
||||
@@ -187,7 +198,7 @@ describe('flows/index', function() {
|
||||
})
|
||||
});
|
||||
|
||||
flows.init({settings:{},storage:storage});
|
||||
flows.init({log:mockLog, settings:{},storage:storage});
|
||||
flows.load().then(function() {
|
||||
flows.startFlows();
|
||||
});
|
||||
@@ -216,7 +227,7 @@ describe('flows/index', function() {
|
||||
})
|
||||
});
|
||||
|
||||
flows.init({settings:{},storage:storage});
|
||||
flows.init({log:mockLog, settings:{},storage:storage});
|
||||
flows.load().then(function() {
|
||||
flows.startFlows();
|
||||
});
|
||||
@@ -233,7 +244,7 @@ describe('flows/index', function() {
|
||||
storage.getFlows = function() {
|
||||
return when.resolve({flows:originalConfig});
|
||||
}
|
||||
flows.init({settings:{},storage:storage});
|
||||
flows.init({log:mockLog, settings:{},storage:storage});
|
||||
flows.load().then(function() {
|
||||
credentialsLoad.called.should.be.true();
|
||||
// 'load' type does not trigger a save
|
||||
@@ -259,7 +270,7 @@ describe('flows/index', function() {
|
||||
done();
|
||||
});
|
||||
|
||||
flows.init({settings:{},storage:storage});
|
||||
flows.init({log:mockLog, settings:{},storage:storage});
|
||||
flows.load().then(function() {
|
||||
flows.startFlows();
|
||||
});
|
||||
@@ -274,7 +285,7 @@ describe('flows/index', function() {
|
||||
return when.resolve({flows:originalConfig});
|
||||
}
|
||||
|
||||
flows.init({settings:{},storage:storage});
|
||||
flows.init({log:mockLog, settings:{},storage:storage});
|
||||
flows.load().then(function() {
|
||||
flows.startFlows();
|
||||
flowCreate.called.should.be.false();
|
||||
@@ -292,7 +303,7 @@ describe('flows/index', function() {
|
||||
storage.getFlows = function() {
|
||||
return when.resolve({flows:originalConfig});
|
||||
}
|
||||
flows.init({settings:{},storage:storage});
|
||||
flows.init({log:mockLog, settings:{},storage:storage});
|
||||
flows.load().then(function() {
|
||||
flows.startFlows();
|
||||
flowCreate.called.should.be.false();
|
||||
@@ -326,7 +337,7 @@ describe('flows/index', function() {
|
||||
storage.getFlows = function() {
|
||||
return when.resolve({flows:originalConfig});
|
||||
}
|
||||
flows.init({settings:{},storage:storage});
|
||||
flows.init({log:mockLog, settings:{},storage:storage});
|
||||
flows.load().then(function() {
|
||||
var c = 0;
|
||||
flows.eachNode(function(node) {
|
||||
@@ -357,7 +368,7 @@ describe('flows/index', function() {
|
||||
done();
|
||||
});
|
||||
|
||||
flows.init({settings:{},storage:storage});
|
||||
flows.init({log:mockLog, settings:{},storage:storage});
|
||||
flows.load().then(function() {
|
||||
flows.startFlows();
|
||||
});
|
||||
@@ -388,7 +399,7 @@ describe('flows/index', function() {
|
||||
}
|
||||
});
|
||||
|
||||
flows.init({settings:{},storage:storage});
|
||||
flows.init({log:mockLog, settings:{},storage:storage});
|
||||
flows.load().then(function() {
|
||||
flows.startFlows();
|
||||
});
|
||||
@@ -410,7 +421,7 @@ describe('flows/index', function() {
|
||||
done();
|
||||
});
|
||||
|
||||
flows.init({settings:{},storage:storage});
|
||||
flows.init({log:mockLog, settings:{},storage:storage});
|
||||
flows.load().then(function() {
|
||||
flows.startFlows();
|
||||
});
|
||||
@@ -442,7 +453,7 @@ describe('flows/index', function() {
|
||||
}
|
||||
});
|
||||
|
||||
flows.init({settings:{},storage:storage});
|
||||
flows.init({log:mockLog, settings:{},storage:storage});
|
||||
flows.load().then(function() {
|
||||
flows.startFlows();
|
||||
});
|
||||
@@ -470,7 +481,7 @@ describe('flows/index', function() {
|
||||
{id:"t1-1",x:10,y:10,z:"t1",type:"test",wires:[]},
|
||||
{id:"t1",type:"tab"}
|
||||
];
|
||||
flows.init({settings:{},storage:storage});
|
||||
flows.init({log:mockLog, settings:{},storage:storage});
|
||||
flows.setFlows(originalConfig).then(function() {
|
||||
flows.checkTypeInUse("unused-module");
|
||||
done();
|
||||
@@ -481,7 +492,7 @@ describe('flows/index', function() {
|
||||
{id:"t1-1",x:10,y:10,z:"t1",type:"test",wires:[]},
|
||||
{id:"t1",type:"tab"}
|
||||
];
|
||||
flows.init({settings:{},storage:storage});
|
||||
flows.init({log:mockLog, settings:{},storage:storage});
|
||||
flows.setFlows(originalConfig).then(function() {
|
||||
/*jshint immed: false */
|
||||
try {
|
||||
@@ -504,7 +515,7 @@ describe('flows/index', function() {
|
||||
storage.getFlows = function() {
|
||||
return when.resolve({flows:originalConfig});
|
||||
}
|
||||
flows.init({settings:{},storage:storage});
|
||||
flows.init({log:mockLog, settings:{},storage:storage});
|
||||
flows.load().then(function() {
|
||||
flows.addFlow({
|
||||
label:'new flow',
|
||||
@@ -531,7 +542,7 @@ describe('flows/index', function() {
|
||||
storage.setFlows = function() {
|
||||
return when.resolve();
|
||||
}
|
||||
flows.init({settings:{},storage:storage});
|
||||
flows.init({log:mockLog, settings:{},storage:storage});
|
||||
flows.load().then(function() {
|
||||
return flows.startFlows();
|
||||
}).then(function() {
|
||||
@@ -539,8 +550,7 @@ describe('flows/index', function() {
|
||||
label:'new flow',
|
||||
nodes:[
|
||||
{id:"t2-1",x:10,y:10,z:"t1",type:"test",wires:[]},
|
||||
{id:"t2-2",x:10,y:10,z:"t1",type:"test",wires:[]}
|
||||
,
|
||||
{id:"t2-2",x:10,y:10,z:"t1",type:"test",wires:[]},
|
||||
{id:"t2-3",z:"t1",type:"test"}
|
||||
]
|
||||
}).then(function(id) {
|
||||
|
@@ -19,7 +19,7 @@ var fs = require('fs-extra');
|
||||
var path = require('path');
|
||||
var when = require("when");
|
||||
var sinon = require('sinon');
|
||||
|
||||
console.log(__dirname);
|
||||
var index = require("../../../../red/runtime/nodes/index");
|
||||
var flows = require("../../../../red/runtime/nodes/flows");
|
||||
var registry = require("../../../../red/runtime/nodes/registry");
|
||||
@@ -131,7 +131,7 @@ describe("red/nodes/index", function() {
|
||||
var runtime = require("../../../../red/runtime");
|
||||
var credentials = require("../../../../red/runtime/nodes/credentials");
|
||||
var localfilesystem = require("../../../../red/runtime/storage/localfilesystem");
|
||||
var log = require("../../../../red/runtime/log");
|
||||
var log = require("../../../../red/util/log");
|
||||
var RED = require("../../../../red/red.js");
|
||||
|
||||
var userDir = path.join(__dirname,".testUserHome");
|
||||
|
@@ -28,8 +28,18 @@ var typeRegistry = require("../../../../../red/runtime/nodes/registry/registry")
|
||||
|
||||
describe('nodes/registry/installer', function() {
|
||||
|
||||
var mockLog = {
|
||||
log: sinon.stub(),
|
||||
debug: sinon.stub(),
|
||||
trace: sinon.stub(),
|
||||
warn: sinon.stub(),
|
||||
info: sinon.stub(),
|
||||
metric: sinon.stub(),
|
||||
_: function() { return "abc"}
|
||||
}
|
||||
|
||||
before(function() {
|
||||
installer.init({});
|
||||
installer.init({log:mockLog, settings:{}});
|
||||
});
|
||||
afterEach(function() {
|
||||
if (child_process.spawn.restore) {
|
||||
@@ -74,7 +84,7 @@ describe('nodes/registry/installer', function() {
|
||||
});
|
||||
|
||||
installer.installModule("this_wont_exist").otherwise(function(err) {
|
||||
err.code.should.be.eql(404);
|
||||
err.should.have.property("code",404);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user