1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Move away from __defineGetter syntax, in red and server

Bump test coverage forwards a bit
This commit is contained in:
dceejay 2015-03-06 10:17:00 +00:00
parent 3cbc1bbb1b
commit 234abd82a2
3 changed files with 46 additions and 30 deletions

View File

@ -24,15 +24,12 @@ var fs = require("fs");
var settings = require("./settings"); var settings = require("./settings");
var credentials = require("./nodes/credentials"); var credentials = require("./nodes/credentials");
var auth = require("./api/auth"); var auth = require("./api/auth");
var path = require('path'); var path = require('path');
var events = require("events");
process.env.NODE_RED_HOME = process.env.NODE_RED_HOME || path.resolve(__dirname+"/.."); process.env.NODE_RED_HOME = process.env.NODE_RED_HOME || path.resolve(__dirname+"/..");
var events = require("events");
var RED = { var RED = {
init: function(httpServer,userSettings) { init: function(httpServer,userSettings) {
userSettings.version = this.version(); userSettings.version = this.version();
log.init(userSettings); log.init(userSettings);
@ -40,7 +37,6 @@ var RED = {
server.init(httpServer,settings); server.init(httpServer,settings);
return server.app; return server.app;
}, },
start: server.start, start: server.start,
stop: server.stop, stop: server.stop,
nodes: nodes, nodes: nodes,
@ -55,18 +51,16 @@ var RED = {
needsPermission: auth.needsPermission needsPermission: auth.needsPermission
}, },
version: function () { version: function () {
var p = require(path.join(process.env.NODE_RED_HOME,"package.json")); var p = require(path.join(process.env.NODE_RED_HOME,"package.json")).version;
/* istanbul ignore else */
if (fs.existsSync(path.join(process.env.NODE_RED_HOME,".git"))) { if (fs.existsSync(path.join(process.env.NODE_RED_HOME,".git"))) {
return p.version+".git"; p += ".git";
} else {
return p.version;
} }
} return p;
},
get app() { console.log("Deprecated use of RED.app - use RED.httpAdmin instead"); return server.app },
get httpAdmin() { return server.app },
get httpNode() { return server.nodeApp },
get server() { return server.server }
}; };
RED.__defineGetter__("app", function() { console.log("Deprecated use of RED.app - use RED.httpAdmin instead"); return server.app });
RED.__defineGetter__("httpAdmin", function() { return server.app });
RED.__defineGetter__("httpNode", function() { return server.nodeApp });
RED.__defineGetter__("server", function() { return server.server });
module.exports = RED; module.exports = RED;

View File

@ -242,8 +242,6 @@ function reportMetrics() {
log.log(metrics); log.log(metrics);
} }
function stop() { function stop() {
if (runtimeMetricInterval) { if (runtimeMetricInterval) {
clearInterval(runtimeMetricInterval); clearInterval(runtimeMetricInterval);
@ -261,9 +259,9 @@ module.exports = {
reportAddedModules: reportAddedModules, reportAddedModules: reportAddedModules,
reportRemovedModules: reportRemovedModules, reportRemovedModules: reportRemovedModules,
installModule: installModule, installModule: installModule,
uninstallModule: uninstallModule uninstallModule: uninstallModule,
}
module.exports.__defineGetter__("app", function() { return app }); get app() { return app },
module.exports.__defineGetter__("nodeApp", function() { return nodeApp }); get nodeApp() { return nodeApp },
module.exports.__defineGetter__("server", function() { return server }); get server() { return server }
}

View File

@ -17,6 +17,30 @@ var should = require("should");
describe("red/red", function() { describe("red/red", function() {
it('can be required without errors', function() { it('can be required without errors', function() {
require("../../red/red"); var RED = require("../../red/red");
}); });
var RED = require("../../red/red");
it('returns an app object', function() {
var srv = RED.app.use("/test", function() { return "app"; });
srv.should.be.an.instanceOf(Object);
});
it('returns an httpAdmin object', function() {
var srv = RED.httpAdmin.use("/test", function() { return "Admin"; });
srv.should.be.an.instanceOf(Object);
});
it('reuturns an httpNode object', function() {
var srv = RED.httpNode.use("/test", function() { return "Node"; });
srv.should.be.an.instanceOf(Object);
});
it('it returns a server object', function() {
var srv = RED.server;
srv.should.be.an.instanceOf(Object).and.have.property('domain', null);
srv.should.be.an.instanceOf(Object).and.have.property('timeout', 120000);
});
}); });