mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Update tests for runtime/api separation
This commit is contained in:
parent
f43738446e
commit
9f5e6a4b37
@ -28,7 +28,7 @@ var persistentSettings = {
|
|||||||
userSettings = settings;
|
userSettings = settings;
|
||||||
for (var i in settings) {
|
for (var i in settings) {
|
||||||
/* istanbul ignore else */
|
/* istanbul ignore else */
|
||||||
if (settings.hasOwnProperty(i)) {
|
if (settings.hasOwnProperty(i) && typeof settings[i] !== "function") {
|
||||||
(function() {
|
(function() {
|
||||||
var j = i;
|
var j = i;
|
||||||
persistentSettings.__defineGetter__(j,function() { return userSettings[j]; });
|
persistentSettings.__defineGetter__(j,function() { return userSettings[j]; });
|
||||||
|
@ -28,13 +28,11 @@ describe("api index", function() {
|
|||||||
|
|
||||||
describe("disables editor", function() {
|
describe("disables editor", function() {
|
||||||
before(function() {
|
before(function() {
|
||||||
app = express();
|
api.init({
|
||||||
api.init(app,{
|
settings:{httpNodeRoot:true, httpAdminRoot: true,disableEditor:true},
|
||||||
settings:{disableEditor:true},
|
events: {on:function(){},removeListener: function(){}}
|
||||||
api:{
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
app = api.adminApp();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not serve the editor', function(done) {
|
it('does not serve the editor', function(done) {
|
||||||
@ -69,11 +67,11 @@ describe("api index", function() {
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
before(function() {
|
before(function() {
|
||||||
app = express();
|
api.init({
|
||||||
api.init(app,{
|
settings:{httpNodeRoot:true, httpAdminRoot: true, adminAuth:{type: "credentials",users:[],default:{permissions:"read"}}},
|
||||||
settings:{adminAuth:{type: "credentials",users:[],default:{permissions:"read"}}},
|
|
||||||
storage:{getSessions:function(){return when.resolve({})}}
|
storage:{getSessions:function(){return when.resolve({})}}
|
||||||
});
|
});
|
||||||
|
app = api.adminApp();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('it now serves auth', function(done) {
|
it('it now serves auth', function(done) {
|
||||||
@ -105,12 +103,12 @@ describe("api index", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
before(function() {
|
before(function() {
|
||||||
app = express();
|
api.init({
|
||||||
api.init(app,{
|
|
||||||
log:{audit:function(){}},
|
log:{audit:function(){}},
|
||||||
settings:{disableEditor:false},
|
settings:{httpNodeRoot:true, httpAdminRoot: true,disableEditor:false},
|
||||||
events:{on:function(){},removeListener:function(){}}
|
events:{on:function(){},removeListener:function(){}}
|
||||||
});
|
});
|
||||||
|
app = api.adminApp();
|
||||||
});
|
});
|
||||||
it('serves the editor', function(done) {
|
it('serves the editor', function(done) {
|
||||||
request(app)
|
request(app)
|
||||||
|
@ -21,8 +21,6 @@ var bodyParser = require('body-parser');
|
|||||||
var sinon = require('sinon');
|
var sinon = require('sinon');
|
||||||
var when = require('when');
|
var when = require('when');
|
||||||
|
|
||||||
var settings = require("../../../red/settings");
|
|
||||||
|
|
||||||
var nodes = require("../../../red/api/nodes");
|
var nodes = require("../../../red/api/nodes");
|
||||||
|
|
||||||
describe("nodes api", function() {
|
describe("nodes api", function() {
|
||||||
@ -335,9 +333,6 @@ describe("nodes api", function() {
|
|||||||
});
|
});
|
||||||
describe('delete', function() {
|
describe('delete', function() {
|
||||||
it('returns 400 if settings are unavailable', function(done) {
|
it('returns 400 if settings are unavailable', function(done) {
|
||||||
var settingsAvailable = sinon.stub(settings,'available', function() {
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
initNodes({
|
initNodes({
|
||||||
settings:{available:function(){return false}}
|
settings:{available:function(){return false}}
|
||||||
});
|
});
|
||||||
@ -346,7 +341,6 @@ describe("nodes api", function() {
|
|||||||
.del('/nodes/123')
|
.del('/nodes/123')
|
||||||
.expect(400)
|
.expect(400)
|
||||||
.end(function(err,res) {
|
.end(function(err,res) {
|
||||||
settingsAvailable.restore();
|
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ var when = require('when');
|
|||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
|
|
||||||
var app = express();
|
var app = express();
|
||||||
var settings = require("../../../red/settings");
|
|
||||||
|
|
||||||
var theme = require("../../../red/api/theme");
|
var theme = require("../../../red/api/theme");
|
||||||
|
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
<script type="text/x-red" data-template-name="should-not-load-2"></script>
|
|
||||||
<script type="text/x-red" data-help-name="should-not-load-2"></script>
|
|
||||||
<script type="text/javascript">RED.nodes.registerType('should-not-load-2',{});</script>
|
|
||||||
<style></style>
|
|
@ -1,5 +0,0 @@
|
|||||||
// A test node that exports a function
|
|
||||||
module.exports = function(RED) {
|
|
||||||
function TestNode(n) {}
|
|
||||||
RED.nodes.registerType("should-not-load-2",TestNode);
|
|
||||||
}
|
|
1
test/red/nodes/resources/TestNodeModule/node_modules/EmptyModule/file.txt
generated
vendored
1
test/red/nodes/resources/TestNodeModule/node_modules/EmptyModule/file.txt
generated
vendored
@ -1 +0,0 @@
|
|||||||
This file exists just to ensure the parent directory is in the repository.
|
|
@ -1,5 +0,0 @@
|
|||||||
<script type="text/x-red" data-template-name="test-node-mod-1"></script>
|
|
||||||
<script type="text/x-red" data-help-name="test-node-mod-1"></script>
|
|
||||||
<script type="text/javascript">RED.nodes.registerType('test-node-mod-1',{});</script>
|
|
||||||
<style></style>
|
|
||||||
<p>this should be filtered out</p>
|
|
@ -1,5 +0,0 @@
|
|||||||
// A test node that exports a function
|
|
||||||
module.exports = function(RED) {
|
|
||||||
function TestNode(n) {}
|
|
||||||
RED.nodes.registerType("test-node-mod-1",TestNode);
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
<script type="text/x-red" data-template-name="test-node-mod-2"></script>
|
|
||||||
<script type="text/x-red" data-help-name="test-node-mod-2"></script>
|
|
||||||
<script type="text/javascript">RED.nodes.registerType('test-node-mod-2',{});</script>
|
|
||||||
<style></style>
|
|
||||||
<p>this should be filtered out</p>
|
|
@ -1,4 +0,0 @@
|
|||||||
// A test node that exports a function
|
|
||||||
module.exports = function(RED) {
|
|
||||||
throw new Error("fail to load");
|
|
||||||
}
|
|
3
test/red/nodes/resources/TestNodeModule/node_modules/TestNodeModule/icons/file.txt
generated
vendored
3
test/red/nodes/resources/TestNodeModule/node_modules/TestNodeModule/icons/file.txt
generated
vendored
@ -1,3 +0,0 @@
|
|||||||
This file exists just to ensure the 'icons' directory is in the repository.
|
|
||||||
TODO: a future test needs to ensure the right icon files are loaded - this
|
|
||||||
directory can be used for that
|
|
11
test/red/nodes/resources/TestNodeModule/node_modules/TestNodeModule/package.json
generated
vendored
11
test/red/nodes/resources/TestNodeModule/node_modules/TestNodeModule/package.json
generated
vendored
@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"name" : "TestNodeModule",
|
|
||||||
"version" : "0.0.1",
|
|
||||||
"description" : "A test node module",
|
|
||||||
"node-red" : {
|
|
||||||
"nodes": {
|
|
||||||
"TestNodeMod1": "TestNodeModule.js",
|
|
||||||
"TestNodeMod2": "TestNodeModule2.js"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,30 +19,27 @@ var fs = require("fs");
|
|||||||
var path = require("path");
|
var path = require("path");
|
||||||
|
|
||||||
var RED = require("../../red/red");
|
var RED = require("../../red/red");
|
||||||
var log = require("../../red/log");
|
var runtime = require("../../red/runtime");
|
||||||
var settings = require("../../red/settings");
|
var api = require("../../red/api");
|
||||||
var server = require("../../red/server");
|
|
||||||
|
|
||||||
|
|
||||||
describe("red/red", function() {
|
describe("red/red", function() {
|
||||||
|
|
||||||
describe("check build", function() {
|
describe("check build", function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
sinon.stub(log,"init",function() {});
|
sinon.stub(runtime,"init",function() {});
|
||||||
sinon.stub(settings,"init",function() {});
|
sinon.stub(api,"init",function() {});
|
||||||
sinon.stub(server,"init",function() {});
|
|
||||||
sinon.stub(RED,"version",function() { return "version";});
|
sinon.stub(RED,"version",function() { return "version";});
|
||||||
});
|
});
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
log.init.restore();
|
runtime.init.restore();
|
||||||
settings.init.restore();
|
api.init.restore();
|
||||||
server.init.restore();
|
|
||||||
fs.statSync.restore();
|
fs.statSync.restore();
|
||||||
RED.version.restore();
|
RED.version.restore();
|
||||||
});
|
});
|
||||||
it('warns if build has not been run',function() {
|
it('warns if build has not been run',function() {
|
||||||
sinon.stub(fs,"statSync",function() { throw new Error();});
|
sinon.stub(fs,"statSync",function() { throw new Error();});
|
||||||
|
|
||||||
/*jshint immed: false */
|
/*jshint immed: false */
|
||||||
(function() {
|
(function() {
|
||||||
RED.init({},{});
|
RED.init({},{});
|
||||||
@ -53,19 +50,22 @@ describe("red/red", function() {
|
|||||||
RED.init({},{});
|
RED.init({},{});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("externals", function() {
|
describe("externals", function() {
|
||||||
it('reports version', function() {
|
it('reports version', function() {
|
||||||
var p = require(path.join(process.env.NODE_RED_HOME,"package.json")).version;
|
var p = require(path.join(process.env.NODE_RED_HOME,"package.json")).version;
|
||||||
RED.version().indexOf(p).should.eql(0);
|
RED.version().indexOf(p).should.eql(0);
|
||||||
});
|
});
|
||||||
it('access server externals', function() {
|
it.skip('access server externals', function() {
|
||||||
// TODO: unstubable accessors - need to make this testable
|
// TODO: unstubable accessors - need to make this testable
|
||||||
RED.app;
|
RED.app;
|
||||||
RED.httpAdmin;
|
RED.httpAdmin;
|
||||||
RED.httpNode;
|
RED.httpNode;
|
||||||
RED.server;
|
RED.server;
|
||||||
});
|
});
|
||||||
|
it.skip('only initialises api component if httpAdmin enabled');
|
||||||
|
it.skip('stubs httpAdmin if httpAdmin disabled');
|
||||||
|
it.skip('stubs httpNode if httpNode disabled');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -23,14 +23,14 @@ var express = require('express');
|
|||||||
var app = express();
|
var app = express();
|
||||||
var WebSocket = require('ws');
|
var WebSocket = require('ws');
|
||||||
|
|
||||||
var comms = require("../../red/comms.js");
|
var comms = require("../../../red/runtime/comms");
|
||||||
var Users = require("../../red/api/auth/users");
|
var Users = require("../../../red/api/auth/users");
|
||||||
var Tokens = require("../../red/api/auth/tokens");
|
var Tokens = require("../../../red/api/auth/tokens");
|
||||||
|
|
||||||
var address = '127.0.0.1';
|
var address = '127.0.0.1';
|
||||||
var listenPort = 0; // use ephemeral port
|
var listenPort = 0; // use ephemeral port
|
||||||
|
|
||||||
describe("comms", function() {
|
describe("runtime/comms", function() {
|
||||||
describe("with default keepalive", function() {
|
describe("with default keepalive", function() {
|
||||||
var server;
|
var server;
|
||||||
var url;
|
var url;
|
||||||
@ -46,11 +46,11 @@ describe("comms", function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function() {
|
after(function() {
|
||||||
comms.stop();
|
comms.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accepts connection', function(done) {
|
it('accepts connection', function(done) {
|
||||||
var ws = new WebSocket(url);
|
var ws = new WebSocket(url);
|
||||||
ws.on('open', function() {
|
ws.on('open', function() {
|
||||||
@ -58,7 +58,7 @@ describe("comms", function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('publishes message after subscription', function(done) {
|
it('publishes message after subscription', function(done) {
|
||||||
var ws = new WebSocket(url);
|
var ws = new WebSocket(url);
|
||||||
ws.on('open', function() {
|
ws.on('open', function() {
|
||||||
@ -71,7 +71,7 @@ describe("comms", function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('publishes retained message for subscription', function(done) {
|
it('publishes retained message for subscription', function(done) {
|
||||||
comms.publish('topic2', 'bar', true);
|
comms.publish('topic2', 'bar', true);
|
||||||
var ws = new WebSocket(url);
|
var ws = new WebSocket(url);
|
||||||
@ -84,7 +84,7 @@ describe("comms", function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('retained message is deleted by non-retained message', function(done) {
|
it('retained message is deleted by non-retained message', function(done) {
|
||||||
comms.publish('topic3', 'retained', true);
|
comms.publish('topic3', 'retained', true);
|
||||||
comms.publish('topic3', 'non-retained');
|
comms.publish('topic3', 'non-retained');
|
||||||
@ -99,7 +99,7 @@ describe("comms", function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('malformed messages are ignored',function(done) {
|
it('malformed messages are ignored',function(done) {
|
||||||
var ws = new WebSocket(url);
|
var ws = new WebSocket(url);
|
||||||
ws.on('open', function() {
|
ws.on('open', function() {
|
||||||
@ -114,11 +114,11 @@ describe("comms", function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// The following test currently fails due to minimum viable
|
// The following test currently fails due to minimum viable
|
||||||
// implementation. More test should be written to test topic
|
// implementation. More test should be written to test topic
|
||||||
// matching once this one is passing
|
// matching once this one is passing
|
||||||
|
|
||||||
if (0) {
|
if (0) {
|
||||||
it('receives message on correct topic', function(done) {
|
it('receives message on correct topic', function(done) {
|
||||||
var ws = new WebSocket(url);
|
var ws = new WebSocket(url);
|
||||||
@ -150,11 +150,11 @@ describe("comms", function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function() {
|
after(function() {
|
||||||
comms.stop();
|
comms.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rejects websocket connections',function(done) {
|
it('rejects websocket connections',function(done) {
|
||||||
var ws = new WebSocket(url);
|
var ws = new WebSocket(url);
|
||||||
ws.on('open', function() {
|
ws.on('open', function() {
|
||||||
@ -164,10 +164,10 @@ describe("comms", function() {
|
|||||||
ws.on('error', function() {
|
ws.on('error', function() {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("non-default httpAdminRoot set: /adminPath", function() {
|
describe("non-default httpAdminRoot set: /adminPath", function() {
|
||||||
var server;
|
var server;
|
||||||
var url;
|
var url;
|
||||||
@ -183,11 +183,11 @@ describe("comms", function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function() {
|
after(function() {
|
||||||
comms.stop();
|
comms.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accepts connections',function(done) {
|
it('accepts connections',function(done) {
|
||||||
var ws = new WebSocket(url);
|
var ws = new WebSocket(url);
|
||||||
ws.on('open', function() {
|
ws.on('open', function() {
|
||||||
@ -197,10 +197,10 @@ describe("comms", function() {
|
|||||||
ws.on('error', function() {
|
ws.on('error', function() {
|
||||||
done(new Error("Socket connection failed"));
|
done(new Error("Socket connection failed"));
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("non-default httpAdminRoot set: /adminPath/", function() {
|
describe("non-default httpAdminRoot set: /adminPath/", function() {
|
||||||
var server;
|
var server;
|
||||||
var url;
|
var url;
|
||||||
@ -216,11 +216,11 @@ describe("comms", function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function() {
|
after(function() {
|
||||||
comms.stop();
|
comms.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accepts connections',function(done) {
|
it('accepts connections',function(done) {
|
||||||
var ws = new WebSocket(url);
|
var ws = new WebSocket(url);
|
||||||
ws.on('open', function() {
|
ws.on('open', function() {
|
||||||
@ -230,10 +230,10 @@ describe("comms", function() {
|
|||||||
ws.on('error', function() {
|
ws.on('error', function() {
|
||||||
done(new Error("Socket connection failed"));
|
done(new Error("Socket connection failed"));
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("non-default httpAdminRoot set: adminPath", function() {
|
describe("non-default httpAdminRoot set: adminPath", function() {
|
||||||
var server;
|
var server;
|
||||||
var url;
|
var url;
|
||||||
@ -249,11 +249,11 @@ describe("comms", function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function() {
|
after(function() {
|
||||||
comms.stop();
|
comms.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accepts connections',function(done) {
|
it('accepts connections',function(done) {
|
||||||
var ws = new WebSocket(url);
|
var ws = new WebSocket(url);
|
||||||
ws.on('open', function() {
|
ws.on('open', function() {
|
||||||
@ -263,10 +263,10 @@ describe("comms", function() {
|
|||||||
ws.on('error', function() {
|
ws.on('error', function() {
|
||||||
done(new Error("Socket connection failed"));
|
done(new Error("Socket connection failed"));
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("keep alives", function() {
|
describe("keep alives", function() {
|
||||||
var server;
|
var server;
|
||||||
var url;
|
var url;
|
||||||
@ -325,7 +325,7 @@ describe("comms", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('authentication required, no anonymous',function() {
|
describe('authentication required, no anonymous',function() {
|
||||||
var server;
|
var server;
|
||||||
var url;
|
var url;
|
||||||
@ -351,8 +351,8 @@ describe("comms", function() {
|
|||||||
return when.resolve(null);
|
return when.resolve(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
server = http.createServer(function(req,res){app(req,res)});
|
server = http.createServer(function(req,res){app(req,res)});
|
||||||
comms.init(server, {adminAuth:{}});
|
comms.init(server, {adminAuth:{}});
|
||||||
server.listen(listenPort, address);
|
server.listen(listenPort, address);
|
||||||
@ -369,7 +369,7 @@ describe("comms", function() {
|
|||||||
getToken.restore();
|
getToken.restore();
|
||||||
comms.stop();
|
comms.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('prevents connections that do not authenticate',function(done) {
|
it('prevents connections that do not authenticate',function(done) {
|
||||||
var ws = new WebSocket(url);
|
var ws = new WebSocket(url);
|
||||||
var count = 0;
|
var count = 0;
|
||||||
@ -381,7 +381,7 @@ describe("comms", function() {
|
|||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('allows connections that do authenticate',function(done) {
|
it('allows connections that do authenticate',function(done) {
|
||||||
var ws = new WebSocket(url);
|
var ws = new WebSocket(url);
|
||||||
var received = 0;
|
var received = 0;
|
||||||
@ -399,7 +399,7 @@ describe("comms", function() {
|
|||||||
ws.close();
|
ws.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ws.on('close', function() {
|
ws.on('close', function() {
|
||||||
try {
|
try {
|
||||||
received.should.equal(2);
|
received.should.equal(2);
|
||||||
@ -409,7 +409,7 @@ describe("comms", function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rejects connections for non-existant token',function(done) {
|
it('rejects connections for non-existant token',function(done) {
|
||||||
var ws = new WebSocket(url);
|
var ws = new WebSocket(url);
|
||||||
var received = 0;
|
var received = 0;
|
||||||
@ -453,7 +453,7 @@ describe("comms", function() {
|
|||||||
getDefaultUser.restore();
|
getDefaultUser.restore();
|
||||||
comms.stop();
|
comms.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('allows anonymous connections that do not authenticate',function(done) {
|
it('allows anonymous connections that do not authenticate',function(done) {
|
||||||
var ws = new WebSocket(url);
|
var ws = new WebSocket(url);
|
||||||
var count = 0;
|
var count = 0;
|
||||||
@ -480,5 +480,5 @@ describe("comms", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
@ -15,8 +15,9 @@
|
|||||||
**/
|
**/
|
||||||
var should = require("should");
|
var should = require("should");
|
||||||
|
|
||||||
describe("red/events", function() {
|
describe("runtime/events", function() {
|
||||||
it('can be required without errors', function() {
|
it('can be required without errors', function() {
|
||||||
require("../../red/events");
|
require("../../../red/runtime/events");
|
||||||
});
|
});
|
||||||
|
it.skip('more tests needed', function(){})
|
||||||
});
|
});
|
22
test/red/runtime/i18n_spec.js
Normal file
22
test/red/runtime/i18n_spec.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2015 IBM Corp.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
**/
|
||||||
|
|
||||||
|
describe("runtime/i18n", function() {
|
||||||
|
it('can be required without errors', function() {
|
||||||
|
require("../../../red/runtime/i18n");
|
||||||
|
});
|
||||||
|
it.skip('more tests needed', function(){})
|
||||||
|
});
|
@ -16,16 +16,18 @@
|
|||||||
var should = require("should");
|
var should = require("should");
|
||||||
var when = require("when");
|
var when = require("when");
|
||||||
var sinon = require("sinon");
|
var sinon = require("sinon");
|
||||||
|
var path = require("path");
|
||||||
|
|
||||||
var comms = require("../../red/comms");
|
var api = require("../../../red/api");
|
||||||
var redNodes = require("../../red/nodes");
|
var runtime = require("../../../red/runtime");
|
||||||
var api = require("../../red/api");
|
|
||||||
var runtime = require("../../red/runtime");
|
|
||||||
var storage = require("../../red/storage");
|
|
||||||
var settings = require("../../red/settings");
|
|
||||||
var log = require("../../red/log");
|
|
||||||
|
|
||||||
describe("red/runtime", function() {
|
var comms = require("../../../red/runtime/comms");
|
||||||
|
var redNodes = require("../../../red/runtime/nodes");
|
||||||
|
var storage = require("../../../red/runtime/storage");
|
||||||
|
var settings = require("../../../red/runtime/settings");
|
||||||
|
var log = require("../../../red/runtime/log");
|
||||||
|
|
||||||
|
describe("runtime", function() {
|
||||||
var commsMessages = [];
|
var commsMessages = [];
|
||||||
var commsPublish;
|
var commsPublish;
|
||||||
|
|
||||||
@ -42,47 +44,39 @@ describe("red/runtime", function() {
|
|||||||
commsPublish = sinon.stub(comms,"publish", function(topic,msg,retained) {
|
commsPublish = sinon.stub(comms,"publish", function(topic,msg,retained) {
|
||||||
commsMessages.push({topic:topic,msg:msg,retained:retained});
|
commsMessages.push({topic:topic,msg:msg,retained:retained});
|
||||||
});
|
});
|
||||||
|
process.env.NODE_RED_HOME = path.resolve(path.join(__dirname,"..","..",".."))
|
||||||
});
|
});
|
||||||
after(function() {
|
after(function() {
|
||||||
commsPublish.restore();
|
commsPublish.restore();
|
||||||
|
delete process.env.NODE_RED_HOME;
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("init", function() {
|
describe("init", function() {
|
||||||
var commsInit;
|
|
||||||
var apiInit;
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
commsInit = sinon.stub(comms,"init",function() {});
|
sinon.stub(log,"init",function() {});
|
||||||
apiInit = sinon.stub(api,"init",function() {});
|
sinon.stub(settings,"init",function() {});
|
||||||
|
sinon.stub(comms,"init",function() {});
|
||||||
});
|
});
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
commsInit.restore();
|
log.init.restore();
|
||||||
apiInit.restore();
|
settings.init.restore();
|
||||||
|
comms.init.restore();
|
||||||
})
|
})
|
||||||
|
|
||||||
it("initialises components", function() {
|
it("initialises components", function() {
|
||||||
var dummyServer = {};
|
var dummyServer = {};
|
||||||
runtime.init(dummyServer,{testSettings: true, httpAdminRoot:"/", load:function() { return when.resolve();}});
|
runtime.init(dummyServer,{testSettings: true, httpAdminRoot:"/"});
|
||||||
commsInit.called.should.be.true;
|
log.init.called.should.be.true;
|
||||||
apiInit.called.should.be.true;
|
settings.init.called.should.be.true;
|
||||||
|
comms.init.called.should.be.true;
|
||||||
should.exist(runtime.app);
|
|
||||||
should.exist(runtime.nodeApp);
|
|
||||||
|
|
||||||
runtime.server.should.equal(dummyServer);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("doesn't init api if httpAdminRoot set to false",function() {
|
it("returns version", function() {
|
||||||
|
|
||||||
var dummyServer = {};
|
var dummyServer = {};
|
||||||
runtime.init(dummyServer,{testSettings: true, httpAdminRoot:false, load:function() { return when.resolve();}});
|
runtime.init(dummyServer,{testSettings: true, httpAdminRoot:"/"});
|
||||||
commsInit.called.should.be.true;
|
/^\d+\.\d+\.\d+(-git)?$/.test(runtime.version()).should.be.true;
|
||||||
apiInit.called.should.be.false;
|
|
||||||
|
|
||||||
should.exist(runtime.app);
|
})
|
||||||
should.exist(runtime.nodeApp);
|
|
||||||
|
|
||||||
runtime.server.should.equal(dummyServer);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("start",function() {
|
describe("start",function() {
|
@ -17,13 +17,9 @@ var should = require("should");
|
|||||||
var sinon = require("sinon");
|
var sinon = require("sinon");
|
||||||
var util = require("util");
|
var util = require("util");
|
||||||
|
|
||||||
var log = require("../../red/log");
|
var log = require("../../../red/runtime/log");
|
||||||
|
|
||||||
describe("red/log", function() {
|
|
||||||
it('can be required without errors', function() {
|
|
||||||
require("../../red/log");
|
|
||||||
});
|
|
||||||
|
|
||||||
|
describe("runtime/log", function() {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
var spy = sinon.stub(util, 'log', function(arg){});
|
var spy = sinon.stub(util, 'log', function(arg){});
|
||||||
var settings = {logging: { console: { level: 'metric', metrics: true } } };
|
var settings = {logging: { console: { level: 'metric', metrics: true } } };
|
||||||
@ -48,12 +44,12 @@ describe("red/log", function() {
|
|||||||
var ret = log.debug("This is a debug");
|
var ret = log.debug("This is a debug");
|
||||||
sinon.assert.calledWithMatch(util.log,"[debug] This is a debug");
|
sinon.assert.calledWithMatch(util.log,"[debug] This is a debug");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('it can raise a info', function() {
|
it('it can raise a info', function() {
|
||||||
var ret = log.info("This is an info");
|
var ret = log.info("This is an info");
|
||||||
sinon.assert.calledWithMatch(util.log,"[info] This is an info");
|
sinon.assert.calledWithMatch(util.log,"[info] This is an info");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('it can raise a warn', function() {
|
it('it can raise a warn', function() {
|
||||||
var ret = log.warn("This is a warn");
|
var ret = log.warn("This is a warn");
|
||||||
sinon.assert.calledWithMatch(util.log,"[warn] This is a warn");
|
sinon.assert.calledWithMatch(util.log,"[warn] This is a warn");
|
||||||
@ -95,7 +91,7 @@ describe("red/log", function() {
|
|||||||
util.log.calledOnce.should.be.true;
|
util.log.calledOnce.should.be.true;
|
||||||
util.log.firstCall.args[0].indexOf("[nodeType:nodeId]").should.not.equal(-1);
|
util.log.firstCall.args[0].indexOf("[nodeType:nodeId]").should.not.equal(-1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('ignores lower level messages and metrics', function() {
|
it('ignores lower level messages and metrics', function() {
|
||||||
var settings = {logging: { console: { level: 'warn', metrics: false } } };
|
var settings = {logging: { console: { level: 'warn', metrics: false } } };
|
||||||
log.init(settings);
|
log.init(settings);
|
@ -16,10 +16,10 @@
|
|||||||
|
|
||||||
var should = require("should");
|
var should = require("should");
|
||||||
var sinon = require('sinon');
|
var sinon = require('sinon');
|
||||||
var RedNode = require("../../../red/nodes/Node");
|
var RedNode = require("../../../../red/runtime/nodes/Node");
|
||||||
var Log = require("../../../red/log");
|
var Log = require("../../../../red/runtime/log");
|
||||||
var flows = require("../../../red/nodes/flows");
|
var flows = require("../../../../red/runtime/nodes/flows");
|
||||||
var comms = require('../../../red/comms');
|
var comms = require("../../../../red/runtime/comms");
|
||||||
|
|
||||||
describe('Node', function() {
|
describe('Node', function() {
|
||||||
describe('#constructor',function() {
|
describe('#constructor',function() {
|
@ -22,10 +22,10 @@ var util = require("util");
|
|||||||
var express = require("express");
|
var express = require("express");
|
||||||
var request = require("supertest");
|
var request = require("supertest");
|
||||||
|
|
||||||
var index = require("../../../red/nodes/index");
|
var index = require("../../../../red/runtime/nodes/index");
|
||||||
var credentials = require("../../../red/nodes/credentials");
|
var credentials = require("../../../../red/runtime/nodes/credentials");
|
||||||
var log = require("../../../red/log");
|
var log = require("../../../../red/runtime/log");
|
||||||
var auth = require("../../../red/api/auth");
|
var auth = require("../../../../red/api/auth");
|
||||||
|
|
||||||
|
|
||||||
describe('Credentials', function() {
|
describe('Credentials', function() {
|
@ -20,11 +20,11 @@ var sinon = require('sinon');
|
|||||||
var clone = require('clone');
|
var clone = require('clone');
|
||||||
var util = require("util");
|
var util = require("util");
|
||||||
|
|
||||||
var flowUtils = require("../../../../red/nodes/flows/util");
|
var flowUtils = require("../../../../../red/runtime/nodes/flows/util");
|
||||||
var Flow = require("../../../../red/nodes/flows/Flow");
|
var Flow = require("../../../../../red/runtime/nodes/flows/Flow");
|
||||||
var flows = require("../../../../red/nodes/flows");
|
var flows = require("../../../../../red/runtime/nodes/flows");
|
||||||
var Node = require("../../../../red/nodes/Node");
|
var Node = require("../../../../../red/runtime/nodes/Node");
|
||||||
var typeRegistry = require("../../../../red/nodes/registry");
|
var typeRegistry = require("../../../../../red/runtime/nodes/registry");
|
||||||
|
|
||||||
|
|
||||||
describe('Flow', function() {
|
describe('Flow', function() {
|
@ -18,13 +18,13 @@ var should = require("should");
|
|||||||
var sinon = require("sinon");
|
var sinon = require("sinon");
|
||||||
var when = require("when");
|
var when = require("when");
|
||||||
var clone = require("clone");
|
var clone = require("clone");
|
||||||
var flows = require("../../../../red/nodes/flows");
|
var flows = require("../../../../../red/runtime/nodes/flows");
|
||||||
var RedNode = require("../../../../red/nodes/Node");
|
var RedNode = require("../../../../../red/runtime/nodes/Node");
|
||||||
var RED = require("../../../../red/nodes");
|
var RED = require("../../../../../red/runtime/nodes");
|
||||||
var events = require("../../../../red/events");
|
var events = require("../../../../../red/runtime/events");
|
||||||
var credentials = require("../../../../red/nodes/credentials");
|
var credentials = require("../../../../../red/runtime/nodes/credentials");
|
||||||
var typeRegistry = require("../../../../red/nodes/registry");
|
var typeRegistry = require("../../../../../red/runtime/nodes/registry");
|
||||||
var Flow = require("../../../../red/nodes/flows/Flow");
|
var Flow = require("../../../../../red/runtime/nodes/flows/Flow");
|
||||||
|
|
||||||
describe('flows/index', function() {
|
describe('flows/index', function() {
|
||||||
|
|
@ -18,9 +18,9 @@ var should = require("should");
|
|||||||
var sinon = require("sinon");
|
var sinon = require("sinon");
|
||||||
var when = require("when");
|
var when = require("when");
|
||||||
var clone = require("clone");
|
var clone = require("clone");
|
||||||
var flowUtil = require("../../../../red/nodes/flows/util");
|
var flowUtil = require("../../../../../red/runtime/nodes/flows/util");
|
||||||
var typeRegistry = require("../../../../red/nodes/registry");
|
var typeRegistry = require("../../../../../red/runtime/nodes/registry");
|
||||||
var redUtil = require("../../../../red/util");
|
var redUtil = require("../../../../../red/runtime/util");
|
||||||
|
|
||||||
describe('flows/util', function() {
|
describe('flows/util', function() {
|
||||||
var getType;
|
var getType;
|
@ -20,16 +20,18 @@ var path = require('path');
|
|||||||
var when = require("when");
|
var when = require("when");
|
||||||
var sinon = require('sinon');
|
var sinon = require('sinon');
|
||||||
|
|
||||||
var index = require("../../../red/nodes/index");
|
var index = require("../../../../red/runtime/nodes/index");
|
||||||
var flows = require("../../../red/nodes/flows");
|
var flows = require("../../../../red/runtime/nodes/flows");
|
||||||
var registry = require("../../../red/nodes/registry");
|
var registry = require("../../../../red/runtime/nodes/registry");
|
||||||
|
|
||||||
describe("red/nodes/index", function() {
|
describe("red/nodes/index", function() {
|
||||||
before(function() {
|
before(function() {
|
||||||
sinon.stub(flows,"startFlows");
|
sinon.stub(flows,"startFlows");
|
||||||
|
process.env.NODE_RED_HOME = path.resolve(path.join(__dirname,"..","..","..",".."))
|
||||||
});
|
});
|
||||||
after(function() {
|
after(function() {
|
||||||
flows.startFlows.restore();
|
flows.startFlows.restore();
|
||||||
|
delete process.env.NODE_RED_HOME;
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
@ -93,10 +95,10 @@ describe("red/nodes/index", function() {
|
|||||||
var http = require('http');
|
var http = require('http');
|
||||||
var express = require('express');
|
var express = require('express');
|
||||||
var app = express();
|
var app = express();
|
||||||
var server = require("../../../red/server");
|
var runtime = require("../../../../red/runtime");
|
||||||
var credentials = require("../../../red/nodes/credentials");
|
var credentials = require("../../../../red/runtime/nodes/credentials");
|
||||||
var localfilesystem = require("../../../red/storage/localfilesystem");
|
var localfilesystem = require("../../../../red/runtime/storage/localfilesystem");
|
||||||
var RED = require("../../../red/red.js");
|
var RED = require("../../../../red/red.js");
|
||||||
|
|
||||||
var userDir = path.join(__dirname,".testUserHome");
|
var userDir = path.join(__dirname,".testUserHome");
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
@ -114,7 +116,7 @@ describe("red/nodes/index", function() {
|
|||||||
}) ;
|
}) ;
|
||||||
RED.init(http.createServer(function(req,res){app(req,res)}),
|
RED.init(http.createServer(function(req,res){app(req,res)}),
|
||||||
{userDir: userDir});
|
{userDir: userDir});
|
||||||
server.start().then(function () {
|
runtime.start().then(function () {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -123,7 +125,7 @@ describe("red/nodes/index", function() {
|
|||||||
|
|
||||||
after(function(done) {
|
after(function(done) {
|
||||||
fs.remove(userDir,done);
|
fs.remove(userDir,done);
|
||||||
server.stop();
|
runtime.stop();
|
||||||
index.load.restore();
|
index.load.restore();
|
||||||
localfilesystem.getCredentials.restore();
|
localfilesystem.getCredentials.restore();
|
||||||
});
|
});
|
||||||
@ -142,7 +144,7 @@ describe("red/nodes/index", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('allows nodes to be added/removed/enabled/disabled from the registry', function() {
|
describe('allows nodes to be added/removed/enabled/disabled from the registry', function() {
|
||||||
var registry = require("../../../red/nodes/registry");
|
var registry = require("../../../../red/runtime/nodes/registry");
|
||||||
var randomNodeInfo = {id:"5678",types:["random"]};
|
var randomNodeInfo = {id:"5678",types:["random"]};
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
@ -210,7 +212,7 @@ describe("red/nodes/index", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('allows modules to be removed from the registry', function() {
|
describe('allows modules to be removed from the registry', function() {
|
||||||
var registry = require("../../../red/nodes/registry");
|
var registry = require("../../../../red/runtime/nodes/registry");
|
||||||
var randomNodeInfo = {id:"5678",types:["random"]};
|
var randomNodeInfo = {id:"5678",types:["random"]};
|
||||||
var randomModuleInfo = {
|
var randomModuleInfo = {
|
||||||
name:"random",
|
name:"random",
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
var should = require("should");
|
var should = require("should");
|
||||||
|
|
||||||
var deprecated = require("../../../../red/nodes/registry/deprecated.js");
|
var deprecated = require("../../../../../red/runtime/nodes/registry/deprecated.js");
|
||||||
|
|
||||||
describe('deprecated', function() {
|
describe('deprecated', function() {
|
||||||
it('should return info on a node',function() {
|
it('should return info on a node',function() {
|
@ -19,10 +19,10 @@ var sinon = require("sinon");
|
|||||||
var path = require("path");
|
var path = require("path");
|
||||||
var when = require("when");
|
var when = require("when");
|
||||||
|
|
||||||
var RedNodes = require("../../../../red/nodes");
|
var RedNodes = require("../../../../../red/runtime/nodes");
|
||||||
var RedNode = require("../../../../red/nodes/Node");
|
var RedNode = require("../../../../../red/runtime/nodes/Node");
|
||||||
var typeRegistry = require("../../../../red/nodes/registry");
|
var typeRegistry = require("../../../../../red/runtime/nodes/registry");
|
||||||
var events = require("../../../../red/events");
|
var events = require("../../../../../red/runtime/events");
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
typeRegistry.clear();
|
typeRegistry.clear();
|
||||||
@ -167,7 +167,7 @@ describe('red/nodes/registry/index', function() {
|
|||||||
resourcesDir + "NestedDirectoryNode" + path.sep + "NestedNode" + path.sep + "icons");
|
resourcesDir + "NestedDirectoryNode" + path.sep + "NestedNode" + path.sep + "icons");
|
||||||
|
|
||||||
eventEmitSpy.secondCall.args[0].should.be.equal("node-locales-dir");
|
eventEmitSpy.secondCall.args[0].should.be.equal("node-locales-dir");
|
||||||
|
|
||||||
eventEmitSpy.thirdCall.args[0].should.be.equal("type-registered");
|
eventEmitSpy.thirdCall.args[0].should.be.equal("type-registered");
|
||||||
eventEmitSpy.thirdCall.args[1].should.be.equal("nested-node-1");
|
eventEmitSpy.thirdCall.args[1].should.be.equal("nested-node-1");
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ describe('red/nodes/registry/index', function() {
|
|||||||
var list = typeRegistry.getNodeList();
|
var list = typeRegistry.getNodeList();
|
||||||
|
|
||||||
list.should.be.an.Array.and.have.lengthOf(1);
|
list.should.be.an.Array.and.have.lengthOf(1);
|
||||||
|
|
||||||
/*jshint immed: false */
|
/*jshint immed: false */
|
||||||
(function(){
|
(function(){
|
||||||
typeRegistry.registerType("test-node-1",{});
|
typeRegistry.registerType("test-node-1",{});
|
||||||
@ -219,7 +219,7 @@ describe('red/nodes/registry/index', function() {
|
|||||||
done(e);
|
done(e);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles nodesDir as a string', function(done) {
|
it('handles nodesDir as a string', function(done) {
|
||||||
|
|
||||||
typeRegistry.init(stubSettings({
|
typeRegistry.init(stubSettings({
|
||||||
@ -312,13 +312,13 @@ describe('red/nodes/registry/index', function() {
|
|||||||
Object.keys(moduleList).should.have.length(1);
|
Object.keys(moduleList).should.have.length(1);
|
||||||
moduleList.should.have.a.property("node-red");
|
moduleList.should.have.a.property("node-red");
|
||||||
Object.keys(moduleList["node-red"].nodes).should.have.length(3);
|
Object.keys(moduleList["node-red"].nodes).should.have.length(3);
|
||||||
|
|
||||||
nodeList.should.be.Array.and.have.length(3);
|
nodeList.should.be.Array.and.have.length(3);
|
||||||
|
|
||||||
settingsSave.callCount.should.equal(1);
|
settingsSave.callCount.should.equal(1);
|
||||||
settingsSave.firstCall.args[0].should.be.equal("nodes");
|
settingsSave.firstCall.args[0].should.be.equal("nodes");
|
||||||
var savedList = settingsSave.firstCall.args[1];
|
var savedList = settingsSave.firstCall.args[1];
|
||||||
|
|
||||||
moduleList['node-red'].nodes['TestNode1'].should.have.a.property("id","node-red/TestNode1");
|
moduleList['node-red'].nodes['TestNode1'].should.have.a.property("id","node-red/TestNode1");
|
||||||
moduleList['node-red'].nodes['TestNode1'].should.have.a.property("name","TestNode1");
|
moduleList['node-red'].nodes['TestNode1'].should.have.a.property("name","TestNode1");
|
||||||
moduleList['node-red'].nodes['TestNode1'].should.have.a.property("module","node-red");
|
moduleList['node-red'].nodes['TestNode1'].should.have.a.property("module","node-red");
|
||||||
@ -336,7 +336,7 @@ describe('red/nodes/registry/index', function() {
|
|||||||
savedList['node-red'].nodes['TestNode1'].should.have.a.property("types",moduleList['node-red'].nodes['TestNode1'].types);
|
savedList['node-red'].nodes['TestNode1'].should.have.a.property("types",moduleList['node-red'].nodes['TestNode1'].types);
|
||||||
savedList['node-red'].nodes['TestNode1'].should.not.have.a.property("config");
|
savedList['node-red'].nodes['TestNode1'].should.not.have.a.property("config");
|
||||||
savedList['node-red'].nodes['TestNode1'].should.not.have.a.property("template");
|
savedList['node-red'].nodes['TestNode1'].should.not.have.a.property("template");
|
||||||
|
|
||||||
|
|
||||||
done();
|
done();
|
||||||
}).catch(function(e) {
|
}).catch(function(e) {
|
||||||
@ -358,11 +358,11 @@ describe('red/nodes/registry/index', function() {
|
|||||||
list[0].should.have.property("types",["test-node-1"]);
|
list[0].should.have.property("types",["test-node-1"]);
|
||||||
list[0].should.have.property("enabled",true);
|
list[0].should.have.property("enabled",true);
|
||||||
list[0].should.not.have.property("err");
|
list[0].should.not.have.property("err");
|
||||||
|
|
||||||
var id = "node-red/TestNode1";
|
var id = "node-red/TestNode1";
|
||||||
var type = "test-node-1";
|
var type = "test-node-1";
|
||||||
|
|
||||||
|
|
||||||
var info = typeRegistry.getNodeInfo(id);
|
var info = typeRegistry.getNodeInfo(id);
|
||||||
info.should.have.property("loaded");
|
info.should.have.property("loaded");
|
||||||
delete info.loaded;
|
delete info.loaded;
|
||||||
@ -379,7 +379,7 @@ describe('red/nodes/registry/index', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns null node info for unrecognised id', function(done) {
|
it('returns null node info for unrecognised id', function(done) {
|
||||||
typeRegistry.init(settings);
|
typeRegistry.init(settings);
|
||||||
typeRegistry.load(resourcesDir + "TestNode1",true).then(function() {
|
typeRegistry.load(resourcesDir + "TestNode1",true).then(function() {
|
||||||
@ -483,10 +483,10 @@ describe('red/nodes/registry/index', function() {
|
|||||||
|
|
||||||
typeRegistry.addModule("TestNodeModule").then(function(modInfo) {
|
typeRegistry.addModule("TestNodeModule").then(function(modInfo) {
|
||||||
var info = typeRegistry.getModuleInfo("TestNodeModule");
|
var info = typeRegistry.getModuleInfo("TestNodeModule");
|
||||||
|
|
||||||
modInfo.should.eql(info);
|
modInfo.should.eql(info);
|
||||||
should.not.exist(typeRegistry.getModuleInfo("does-not-exist"));
|
should.not.exist(typeRegistry.getModuleInfo("does-not-exist"));
|
||||||
|
|
||||||
done();
|
done();
|
||||||
}).catch(function(e) {
|
}).catch(function(e) {
|
||||||
done(e);
|
done(e);
|
||||||
@ -551,15 +551,15 @@ describe('red/nodes/registry/index', function() {
|
|||||||
|
|
||||||
|
|
||||||
eventEmitSpy.callCount.should.equal(3);
|
eventEmitSpy.callCount.should.equal(3);
|
||||||
|
|
||||||
eventEmitSpy.firstCall.args[0].should.be.equal("node-locales-dir");
|
eventEmitSpy.firstCall.args[0].should.be.equal("node-locales-dir");
|
||||||
|
|
||||||
|
|
||||||
eventEmitSpy.secondCall.args[0].should.be.equal("node-icon-dir");
|
eventEmitSpy.secondCall.args[0].should.be.equal("node-icon-dir");
|
||||||
eventEmitSpy.secondCall.args[1].should.be.equal(
|
eventEmitSpy.secondCall.args[1].should.be.equal(
|
||||||
resourcesDir + "TestNodeModule" + path.sep+ "node_modules" + path.sep + "TestNodeModule" + path.sep + "icons");
|
resourcesDir + "TestNodeModule" + path.sep+ "node_modules" + path.sep + "TestNodeModule" + path.sep + "icons");
|
||||||
|
|
||||||
|
|
||||||
eventEmitSpy.thirdCall.args[0].should.be.equal("type-registered");
|
eventEmitSpy.thirdCall.args[0].should.be.equal("type-registered");
|
||||||
eventEmitSpy.thirdCall.args[1].should.be.equal("test-node-mod-1");
|
eventEmitSpy.thirdCall.args[1].should.be.equal("test-node-mod-1");
|
||||||
|
|
||||||
@ -846,24 +846,24 @@ describe('red/nodes/registry/index', function() {
|
|||||||
typeRegistry.disableNode(list[0].id).then(function(info) {
|
typeRegistry.disableNode(list[0].id).then(function(info) {
|
||||||
info.should.have.property("id",list[0].id);
|
info.should.have.property("id",list[0].id);
|
||||||
info.should.have.property("enabled",false);
|
info.should.have.property("enabled",false);
|
||||||
|
|
||||||
var list2 = typeRegistry.getNodeList();
|
var list2 = typeRegistry.getNodeList();
|
||||||
list2.should.be.an.Array.and.have.lengthOf(1);
|
list2.should.be.an.Array.and.have.lengthOf(1);
|
||||||
list2[0].should.have.property("enabled",false);
|
list2[0].should.have.property("enabled",false);
|
||||||
|
|
||||||
typeRegistry.getNodeConfigs().length.should.equal(0);
|
typeRegistry.getNodeConfigs().length.should.equal(0);
|
||||||
|
|
||||||
typeRegistry.enableNode(list[0].id).then(function(info2) {
|
typeRegistry.enableNode(list[0].id).then(function(info2) {
|
||||||
info2.should.have.property("id",list[0].id);
|
info2.should.have.property("id",list[0].id);
|
||||||
info2.should.have.property("enabled",true);
|
info2.should.have.property("enabled",true);
|
||||||
|
|
||||||
var list3 = typeRegistry.getNodeList();
|
var list3 = typeRegistry.getNodeList();
|
||||||
list3.should.be.an.Array.and.have.lengthOf(1);
|
list3.should.be.an.Array.and.have.lengthOf(1);
|
||||||
list3[0].should.have.property("enabled",true);
|
list3[0].should.have.property("enabled",true);
|
||||||
|
|
||||||
var nodeConfig2 = typeRegistry.getNodeConfigs();
|
var nodeConfig2 = typeRegistry.getNodeConfigs();
|
||||||
nodeConfig2.should.eql(nodeConfig);
|
nodeConfig2.should.eql(nodeConfig);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -891,25 +891,25 @@ describe('red/nodes/registry/index', function() {
|
|||||||
info.should.have.property("id",list[0].id);
|
info.should.have.property("id",list[0].id);
|
||||||
info.should.have.property("types",list[0].types);
|
info.should.have.property("types",list[0].types);
|
||||||
info.should.have.property("enabled",false);
|
info.should.have.property("enabled",false);
|
||||||
|
|
||||||
var list2 = typeRegistry.getNodeList();
|
var list2 = typeRegistry.getNodeList();
|
||||||
list2.should.be.an.Array.and.have.lengthOf(1);
|
list2.should.be.an.Array.and.have.lengthOf(1);
|
||||||
list2[0].should.have.property("enabled",false);
|
list2[0].should.have.property("enabled",false);
|
||||||
|
|
||||||
typeRegistry.getNodeConfigs().length.should.equal(0);
|
typeRegistry.getNodeConfigs().length.should.equal(0);
|
||||||
|
|
||||||
typeRegistry.enableNode(list[0].types[0]).then(function(info2) {
|
typeRegistry.enableNode(list[0].types[0]).then(function(info2) {
|
||||||
info2.should.have.property("id",list[0].id);
|
info2.should.have.property("id",list[0].id);
|
||||||
info2.should.have.property("types",list[0].types);
|
info2.should.have.property("types",list[0].types);
|
||||||
info2.should.have.property("enabled",true);
|
info2.should.have.property("enabled",true);
|
||||||
|
|
||||||
var list3 = typeRegistry.getNodeList();
|
var list3 = typeRegistry.getNodeList();
|
||||||
list3.should.be.an.Array.and.have.lengthOf(1);
|
list3.should.be.an.Array.and.have.lengthOf(1);
|
||||||
list3[0].should.have.property("enabled",true);
|
list3[0].should.have.property("enabled",true);
|
||||||
|
|
||||||
var nodeConfig2 = typeRegistry.getNodeConfigs();
|
var nodeConfig2 = typeRegistry.getNodeConfigs();
|
||||||
nodeConfig2.should.eql(nodeConfig);
|
nodeConfig2.should.eql(nodeConfig);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -939,10 +939,10 @@ describe('red/nodes/registry/index', function() {
|
|||||||
done(e);
|
done(e);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("handles unavailable settings", function(done) {
|
it("handles unavailable settings", function(done) {
|
||||||
typeRegistry.init(settings);
|
typeRegistry.init(settings);
|
||||||
|
|
||||||
/*jshint immed: false */
|
/*jshint immed: false */
|
||||||
(function() {
|
(function() {
|
||||||
typeRegistry.enableNode("123");
|
typeRegistry.enableNode("123");
|
||||||
@ -959,7 +959,7 @@ describe('red/nodes/registry/index', function() {
|
|||||||
(function() {
|
(function() {
|
||||||
typeRegistry.removeModule("123");
|
typeRegistry.removeModule("123");
|
||||||
}).should.throw("Settings unavailable");
|
}).should.throw("Settings unavailable");
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -20,9 +20,9 @@ var when = require("when");
|
|||||||
var path = require("path");
|
var path = require("path");
|
||||||
|
|
||||||
var child_process = require('child_process');
|
var child_process = require('child_process');
|
||||||
var installer = require("../../../../red/nodes/registry/installer");
|
var installer = require("../../../../../red/runtime/nodes/registry/installer");
|
||||||
var registry = require("../../../../red/nodes/registry/index");
|
var registry = require("../../../../../red/runtime/nodes/registry/index");
|
||||||
var typeRegistry = require("../../../../red/nodes/registry/registry");
|
var typeRegistry = require("../../../../../red/runtime/nodes/registry/registry");
|
||||||
|
|
||||||
describe('nodes/registry/installer', function() {
|
describe('nodes/registry/installer', function() {
|
||||||
|
|
@ -18,7 +18,7 @@ var should = require("should");
|
|||||||
var when = require("when");
|
var when = require("when");
|
||||||
var sinon = require("sinon");
|
var sinon = require("sinon");
|
||||||
|
|
||||||
var typeRegistry = require("../../../../red/nodes/registry/registry");
|
var typeRegistry = require("../../../../../red/runtime/nodes/registry/registry");
|
||||||
|
|
||||||
describe("red/nodes/registry/registry",function() {
|
describe("red/nodes/registry/registry",function() {
|
||||||
|
|
@ -16,7 +16,7 @@
|
|||||||
var should = require("should");
|
var should = require("should");
|
||||||
var when = require("when");
|
var when = require("when");
|
||||||
|
|
||||||
var settings = require("../../red/settings");
|
var settings = require("../../../red/runtime/settings");
|
||||||
|
|
||||||
|
|
||||||
describe("red/settings", function() {
|
describe("red/settings", function() {
|
||||||
@ -99,7 +99,6 @@ describe("red/settings", function() {
|
|||||||
(function() {
|
(function() {
|
||||||
settings.get("unknown");
|
settings.get("unknown");
|
||||||
}).should.throw();
|
}).should.throw();
|
||||||
|
|
||||||
settings.load(storage).then(function() {
|
settings.load(storage).then(function() {
|
||||||
settings.available().should.be.true;
|
settings.available().should.be.true;
|
||||||
settings.get("globalA").should.equal(789);
|
settings.get("globalA").should.equal(789);
|
@ -15,21 +15,21 @@
|
|||||||
**/
|
**/
|
||||||
var when = require("when");
|
var when = require("when");
|
||||||
var should = require("should");
|
var should = require("should");
|
||||||
var storage = require("../../../red/storage/index");
|
var storage = require("../../../../red/runtime/storage/index");
|
||||||
|
|
||||||
describe("red/storage/index", function() {
|
describe("red/storage/index", function() {
|
||||||
|
|
||||||
it('rejects the promise when settings suggest loading a bad module', function(done) {
|
it('rejects the promise when settings suggest loading a bad module', function(done) {
|
||||||
|
|
||||||
var wrongModule = {
|
var wrongModule = {
|
||||||
storageModule : "thisaintloading"
|
storageModule : "thisaintloading"
|
||||||
};
|
};
|
||||||
|
|
||||||
storage.init(wrongModule).then( function() {
|
storage.init(wrongModule).then( function() {
|
||||||
var one = 1;
|
var one = 1;
|
||||||
var zero = 0;
|
var zero = 0;
|
||||||
try {
|
try {
|
||||||
zero.should.equal(one, "The initialization promise should never get resolved");
|
zero.should.equal(one, "The initialization promise should never get resolved");
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
done(err);
|
done(err);
|
||||||
}
|
}
|
||||||
@ -37,25 +37,25 @@ describe("red/storage/index", function() {
|
|||||||
done(); //successfully rejected promise
|
done(); //successfully rejected promise
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('non-string storage module', function(done) {
|
it('non-string storage module', function(done) {
|
||||||
var initSetsMeToTrue = false;
|
var initSetsMeToTrue = false;
|
||||||
|
|
||||||
var moduleWithBooleanSettingInit = {
|
var moduleWithBooleanSettingInit = {
|
||||||
init : function() {
|
init : function() {
|
||||||
initSetsMeToTrue = true;
|
initSetsMeToTrue = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var setsBooleanModule = {
|
var setsBooleanModule = {
|
||||||
storageModule : moduleWithBooleanSettingInit
|
storageModule : moduleWithBooleanSettingInit
|
||||||
};
|
};
|
||||||
|
|
||||||
storage.init(setsBooleanModule);
|
storage.init(setsBooleanModule);
|
||||||
initSetsMeToTrue.should.be.true;
|
initSetsMeToTrue.should.be.true;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('respects storage interface', function() {
|
it('respects storage interface', function() {
|
||||||
var calledFlagGetFlows = false;
|
var calledFlagGetFlows = false;
|
||||||
var calledFlagGetCredentials = false;
|
var calledFlagGetCredentials = false;
|
||||||
@ -63,7 +63,7 @@ describe("red/storage/index", function() {
|
|||||||
var calledInit = false;
|
var calledInit = false;
|
||||||
var calledFlagGetSettings = false;
|
var calledFlagGetSettings = false;
|
||||||
var calledFlagGetSessions = false;
|
var calledFlagGetSessions = false;
|
||||||
|
|
||||||
var interfaceCheckerModule = {
|
var interfaceCheckerModule = {
|
||||||
init : function (settings) {
|
init : function (settings) {
|
||||||
settings.should.be.an.Object;
|
settings.should.be.an.Object;
|
||||||
@ -114,39 +114,39 @@ describe("red/storage/index", function() {
|
|||||||
body.should.be.true;
|
body.should.be.true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var moduleToLoad = {
|
var moduleToLoad = {
|
||||||
storageModule : interfaceCheckerModule
|
storageModule : interfaceCheckerModule
|
||||||
};
|
};
|
||||||
|
|
||||||
storage.init(moduleToLoad);
|
storage.init(moduleToLoad);
|
||||||
storage.getFlows();
|
storage.getFlows();
|
||||||
storage.saveFlows(true);
|
storage.saveFlows(true);
|
||||||
storage.getCredentials();
|
storage.getCredentials();
|
||||||
storage.saveCredentials(true);
|
storage.saveCredentials(true);
|
||||||
storage.getSettings();
|
storage.getSettings();
|
||||||
storage.saveSettings(true);
|
storage.saveSettings(true);
|
||||||
storage.getSessions();
|
storage.getSessions();
|
||||||
storage.saveSessions(true);
|
storage.saveSessions(true);
|
||||||
storage.getAllFlows();
|
storage.getAllFlows();
|
||||||
storage.getFlow("name");
|
storage.getFlow("name");
|
||||||
storage.saveFlow("name", true);
|
storage.saveFlow("name", true);
|
||||||
storage.getLibraryEntry(true, "name");
|
storage.getLibraryEntry(true, "name");
|
||||||
storage.saveLibraryEntry(true, "name", true, true);
|
storage.saveLibraryEntry(true, "name", true, true);
|
||||||
|
|
||||||
calledInit.should.be.true;
|
calledInit.should.be.true;
|
||||||
calledFlagGetFlows.should.be.true;
|
calledFlagGetFlows.should.be.true;
|
||||||
calledFlagGetCredentials.should.be.true;
|
calledFlagGetCredentials.should.be.true;
|
||||||
calledFlagGetAllFlows.should.be.true;
|
calledFlagGetAllFlows.should.be.true;
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('respects deprecated flow library functions', function() {
|
describe('respects deprecated flow library functions', function() {
|
||||||
|
|
||||||
var savePath;
|
var savePath;
|
||||||
var saveContent;
|
var saveContent;
|
||||||
var saveMeta;
|
var saveMeta;
|
||||||
var saveType;
|
var saveType;
|
||||||
|
|
||||||
var interfaceCheckerModule = {
|
var interfaceCheckerModule = {
|
||||||
init : function (settings) {
|
init : function (settings) {
|
||||||
settings.should.be.an.Object;
|
settings.should.be.an.Object;
|
||||||
@ -170,7 +170,7 @@ describe("red/storage/index", function() {
|
|||||||
return when.resolve();
|
return when.resolve();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var moduleToLoad = {
|
var moduleToLoad = {
|
||||||
storageModule : interfaceCheckerModule
|
storageModule : interfaceCheckerModule
|
||||||
};
|
};
|
||||||
@ -187,7 +187,7 @@ describe("red/storage/index", function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('getFlow',function(done) {
|
it('getFlow',function(done) {
|
||||||
storage.getFlow("/a/test2.json").then(function(res) {
|
storage.getFlow("/a/test2.json").then(function(res) {
|
||||||
try {
|
try {
|
||||||
@ -198,7 +198,7 @@ describe("red/storage/index", function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it ('saveFlow', function (done) {
|
it ('saveFlow', function (done) {
|
||||||
storage.saveFlow("/a/test2.json","new content").then(function(res) {
|
storage.saveFlow("/a/test2.json","new content").then(function(res) {
|
||||||
try {
|
try {
|
||||||
@ -211,10 +211,10 @@ describe("red/storage/index", function() {
|
|||||||
done(err);
|
done(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('handles missing settings/sessions interface', function() {
|
describe('handles missing settings/sessions interface', function() {
|
||||||
before(function() {
|
before(function() {
|
||||||
var interfaceCheckerModule = {
|
var interfaceCheckerModule = {
|
||||||
@ -222,7 +222,7 @@ describe("red/storage/index", function() {
|
|||||||
};
|
};
|
||||||
storage.init({storageModule: interfaceCheckerModule});
|
storage.init({storageModule: interfaceCheckerModule});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('defaults missing getSettings',function(done) {
|
it('defaults missing getSettings',function(done) {
|
||||||
storage.getSettings().then(function(settings) {
|
storage.getSettings().then(function(settings) {
|
||||||
should.not.exist(settings);
|
should.not.exist(settings);
|
||||||
@ -246,5 +246,5 @@ describe("red/storage/index", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
@ -18,7 +18,7 @@ var should = require("should");
|
|||||||
var fs = require('fs-extra');
|
var fs = require('fs-extra');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
|
||||||
var localfilesystem = require("../../../red/storage/localfilesystem");
|
var localfilesystem = require("../../../../red/runtime/storage/localfilesystem");
|
||||||
|
|
||||||
describe('LocalFileSystem', function() {
|
describe('LocalFileSystem', function() {
|
||||||
var userDir = path.join(__dirname,".testUserHome");
|
var userDir = path.join(__dirname,".testUserHome");
|
||||||
@ -41,8 +41,8 @@ describe('LocalFileSystem', function() {
|
|||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should set userDir to NRH is .config.json present',function(done) {
|
it('should set userDir to NRH is .config.json present',function(done) {
|
||||||
var oldNRH = process.env.NODE_RED_HOME;
|
var oldNRH = process.env.NODE_RED_HOME;
|
||||||
process.env.NODE_RED_HOME = path.join(userDir,"NRH");
|
process.env.NODE_RED_HOME = path.join(userDir,"NRH");
|
||||||
@ -64,13 +64,13 @@ describe('LocalFileSystem', function() {
|
|||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set userDir to HOME/.node-red',function(done) {
|
it('should set userDir to HOME/.node-red',function(done) {
|
||||||
var oldNRH = process.env.NODE_RED_HOME;
|
var oldNRH = process.env.NODE_RED_HOME;
|
||||||
process.env.NODE_RED_HOME = path.join(userDir,"NRH");
|
process.env.NODE_RED_HOME = path.join(userDir,"NRH");
|
||||||
var oldHOME = process.env.HOME;
|
var oldHOME = process.env.HOME;
|
||||||
process.env.HOME = path.join(userDir,"HOME");
|
process.env.HOME = path.join(userDir,"HOME");
|
||||||
|
|
||||||
fs.mkdirSync(process.env.HOME);
|
fs.mkdirSync(process.env.HOME);
|
||||||
var settings = {};
|
var settings = {};
|
||||||
localfilesystem.init(settings).then(function() {
|
localfilesystem.init(settings).then(function() {
|
||||||
@ -89,7 +89,7 @@ describe('LocalFileSystem', function() {
|
|||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle missing flow file',function(done) {
|
it('should handle missing flow file',function(done) {
|
||||||
localfilesystem.init({userDir:userDir}).then(function() {
|
localfilesystem.init({userDir:userDir}).then(function() {
|
||||||
var flowFile = 'flows_'+require('os').hostname()+'.json';
|
var flowFile = 'flows_'+require('os').hostname()+'.json';
|
||||||
@ -156,7 +156,7 @@ describe('LocalFileSystem', function() {
|
|||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should format the flows file when flowFilePretty specified',function(done) {
|
it('should format the flows file when flowFilePretty specified',function(done) {
|
||||||
var flowFile = 'test.json';
|
var flowFile = 'test.json';
|
||||||
var flowFilePath = path.join(userDir,flowFile);
|
var flowFilePath = path.join(userDir,flowFile);
|
||||||
@ -177,7 +177,7 @@ describe('LocalFileSystem', function() {
|
|||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should backup the flows file', function(done) {
|
it('should backup the flows file', function(done) {
|
||||||
var defaultFlowFile = 'flows_'+require('os').hostname()+'.json';
|
var defaultFlowFile = 'flows_'+require('os').hostname()+'.json';
|
||||||
var defaultFlowFilePath = path.join(userDir,defaultFlowFile);
|
var defaultFlowFilePath = path.join(userDir,defaultFlowFile);
|
||||||
@ -196,7 +196,7 @@ describe('LocalFileSystem', function() {
|
|||||||
fs.existsSync(flowFilePath).should.be.true;
|
fs.existsSync(flowFilePath).should.be.true;
|
||||||
var content = fs.readFileSync(flowFilePath,'utf8');
|
var content = fs.readFileSync(flowFilePath,'utf8');
|
||||||
var testFlow2 = [{"type":"tab","id":"bc5672ad.2741d8","label":"Sheet 2"}];
|
var testFlow2 = [{"type":"tab","id":"bc5672ad.2741d8","label":"Sheet 2"}];
|
||||||
|
|
||||||
localfilesystem.saveFlows(testFlow2).then(function() {
|
localfilesystem.saveFlows(testFlow2).then(function() {
|
||||||
fs.existsSync(flowFileBackupPath).should.be.true;
|
fs.existsSync(flowFileBackupPath).should.be.true;
|
||||||
fs.existsSync(defaultFlowFilePath).should.be.false;
|
fs.existsSync(defaultFlowFilePath).should.be.false;
|
||||||
@ -206,21 +206,21 @@ describe('LocalFileSystem', function() {
|
|||||||
var content2 = fs.readFileSync(flowFilePath,'utf8');
|
var content2 = fs.readFileSync(flowFilePath,'utf8');
|
||||||
content2.should.not.equal(backupContent);
|
content2.should.not.equal(backupContent);
|
||||||
done();
|
done();
|
||||||
|
|
||||||
}).otherwise(function(err) {
|
}).otherwise(function(err) {
|
||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
}).otherwise(function(err) {
|
}).otherwise(function(err) {
|
||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
}).otherwise(function(err) {
|
}).otherwise(function(err) {
|
||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle missing credentials', function(done) {
|
it('should handle missing credentials', function(done) {
|
||||||
var flowFile = 'test.json';
|
var flowFile = 'test.json';
|
||||||
var flowFilePath = path.join(userDir,flowFile);
|
var flowFilePath = path.join(userDir,flowFile);
|
||||||
@ -266,7 +266,7 @@ describe('LocalFileSystem', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should backup existing credentials', function(done) {
|
it('should backup existing credentials', function(done) {
|
||||||
var flowFile = 'test.json';
|
var flowFile = 'test.json';
|
||||||
var flowFilePath = path.join(userDir,flowFile);
|
var flowFilePath = path.join(userDir,flowFile);
|
||||||
@ -276,7 +276,7 @@ describe('LocalFileSystem', function() {
|
|||||||
localfilesystem.init({userDir:userDir, flowFile:flowFilePath}).then(function() {
|
localfilesystem.init({userDir:userDir, flowFile:flowFilePath}).then(function() {
|
||||||
|
|
||||||
fs.writeFileSync(credFile,"{}","utf8");
|
fs.writeFileSync(credFile,"{}","utf8");
|
||||||
|
|
||||||
fs.existsSync(credFile).should.be.true;
|
fs.existsSync(credFile).should.be.true;
|
||||||
fs.existsSync(credFileBackup).should.be.false;
|
fs.existsSync(credFileBackup).should.be.false;
|
||||||
|
|
||||||
@ -293,8 +293,8 @@ describe('LocalFileSystem', function() {
|
|||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should format the creds file when flowFilePretty specified',function(done) {
|
it('should format the creds file when flowFilePretty specified',function(done) {
|
||||||
var flowFile = 'test.json';
|
var flowFile = 'test.json';
|
||||||
var flowFilePath = path.join(userDir,flowFile);
|
var flowFilePath = path.join(userDir,flowFile);
|
||||||
@ -323,7 +323,7 @@ describe('LocalFileSystem', function() {
|
|||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle non-existent settings', function(done) {
|
it('should handle non-existent settings', function(done) {
|
||||||
var settingsFile = path.join(userDir,".settings.json");
|
var settingsFile = path.join(userDir,".settings.json");
|
||||||
|
|
||||||
@ -339,7 +339,7 @@ describe('LocalFileSystem', function() {
|
|||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle corrupt settings', function(done) {
|
it('should handle corrupt settings', function(done) {
|
||||||
var settingsFile = path.join(userDir,".config.json");
|
var settingsFile = path.join(userDir,".config.json");
|
||||||
fs.writeFileSync(settingsFile,"[This is not json","utf8");
|
fs.writeFileSync(settingsFile,"[This is not json","utf8");
|
||||||
@ -355,7 +355,7 @@ describe('LocalFileSystem', function() {
|
|||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle settings', function(done) {
|
it('should handle settings', function(done) {
|
||||||
var settingsFile = path.join(userDir,".config.json");
|
var settingsFile = path.join(userDir,".config.json");
|
||||||
|
|
||||||
@ -379,7 +379,7 @@ describe('LocalFileSystem', function() {
|
|||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle non-existent sessions', function(done) {
|
it('should handle non-existent sessions', function(done) {
|
||||||
var sessionsFile = path.join(userDir,".sessions.json");
|
var sessionsFile = path.join(userDir,".sessions.json");
|
||||||
|
|
||||||
@ -395,7 +395,7 @@ describe('LocalFileSystem', function() {
|
|||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle corrupt sessions', function(done) {
|
it('should handle corrupt sessions', function(done) {
|
||||||
var sessionsFile = path.join(userDir,".sessions.json");
|
var sessionsFile = path.join(userDir,".sessions.json");
|
||||||
fs.writeFileSync(sessionsFile,"[This is not json","utf8");
|
fs.writeFileSync(sessionsFile,"[This is not json","utf8");
|
||||||
@ -435,8 +435,8 @@ describe('LocalFileSystem', function() {
|
|||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should return an empty list of library objects',function(done) {
|
it('should return an empty list of library objects',function(done) {
|
||||||
localfilesystem.init({userDir:userDir}).then(function() {
|
localfilesystem.init({userDir:userDir}).then(function() {
|
||||||
localfilesystem.getLibraryEntry('object','').then(function(flows) {
|
localfilesystem.getLibraryEntry('object','').then(function(flows) {
|
||||||
@ -513,9 +513,9 @@ describe('LocalFileSystem', function() {
|
|||||||
done(err);
|
done(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a library object',function(done) {
|
it('should return a library object',function(done) {
|
||||||
localfilesystem.init({userDir:userDir}).then(function() {
|
localfilesystem.init({userDir:userDir}).then(function() {
|
||||||
createObjectLibrary();
|
createObjectLibrary();
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
**/
|
**/
|
||||||
var should = require("should");
|
var should = require("should");
|
||||||
var util = require("../../red/util");
|
var util = require("../../../red/runtime/util");
|
||||||
|
|
||||||
describe("red/util", function() {
|
describe("red/util", function() {
|
||||||
describe('generateId', function() {
|
describe('generateId', function() {
|
Loading…
x
Reference in New Issue
Block a user