switch default status to undefined

This commit is contained in:
Spencer Alger 2015-06-15 12:34:33 -07:00
parent 702a796a18
commit 048cd0e293
6 changed files with 11 additions and 18 deletions

View file

@ -65,7 +65,7 @@ module.exports = function (server, plugins) {
if (err) return reject(err);
// Only change the plugin status to green if the intial status has not
// been updated from yellow - Initializing
if (plugin.status.message === 'Initializing' && plugin.status.state === 'yellow') {
if (plugin.status.state === undefined) {
plugin.status.green('Ready');
}
resolve(plugin);

View file

@ -10,7 +10,6 @@ SystemStatus.prototype.createStatus = function (plugin) {
plugin.server.expose('status', plugin.status);
plugin.status.on('change', logStatusChange(plugin));
this.data[plugin.name] = plugin.status;
plugin.status.yellow('Initializing');
};
SystemStatus.prototype.toJSON = function () {

View file

@ -4,8 +4,8 @@ var EventEmitter = require('events').EventEmitter;
util.inherits(Status, EventEmitter);
function Status(name) {
this.name = name;
this.state = 'red';
this.message = '';
this.state = undefined;
this.message = 'uninitialized';
EventEmitter.call(this);
var self = this;
}

View file

@ -93,7 +93,7 @@ describe('server/lib/register_plugins', function () {
expect(createStatus.args[0][0]).to.eql(plugin);
});
});
it('should set the status to yellow and "Initializing" before init is called', function () {
it('should not set the status before init is called', function () {
var next = function (err) {
server.register.args[0][1](err);
};
@ -101,9 +101,7 @@ describe('server/lib/register_plugins', function () {
var plugin = { name: 'first', init: createInit() };
var plugins = [plugin];
return registerPlugins(server, plugins).then(function () {
sinon.assert.calledOnce(yellowSpy);
expect(plugin.init.calledAfter(yellowSpy)).to.be(true);
expect(yellowSpy.args[0][0]).to.be('Initializing');
expect(yellowSpy).to.have.property('callCount', 0);
});
});

View file

@ -26,15 +26,10 @@ describe('lib/status/index.js', function () {
it('should attach a logger to the change status', function () {
status.createStatus(plugin);
plugin.status.green('Ready!');
sinon.assert.calledOnce(plugin.server.log);
});
it('should call the yellow status method with "Initializing"', function () {
status.createStatus(plugin);
sinon.assert.calledOnce(yellowSpy);
expect(yellowSpy.args[0][0]).to.be('Initializing');
});
it('should serialize the statuses when toJSON is called', function () {
status.createStatus(plugin);
expect(JSON.stringify(status)).to.eql(JSON.stringify(status.data));

View file

@ -4,9 +4,10 @@ var Status = require('../../../../../src/server/lib/status/status');
describe('lib/status/status.js', function () {
it('should have a red state when initialized', function () {
it('should have a undefined state when initialized', function () {
var obj = new Status('test');
expect(obj).to.have.property('state', 'red');
expect(obj).to.have.property('state');
expect(obj.statue).to.be(undefined);
});
it('should only trigger the change listner when something changes', function () {
@ -39,7 +40,7 @@ describe('lib/status/status.js', function () {
var message = 'testing ' + color;
obj.on('change', function (current, previous) {
expect(current).to.eql({ state: color, message: message });
expect(previous).to.eql({ state: 'red', message: '' });
expect(previous).to.eql({ state: undefined, message: 'uninitialized' });
done();
});
obj[color](message);
@ -50,7 +51,7 @@ describe('lib/status/status.js', function () {
var message = 'testing ' + color;
obj.on(color, function (msg, prev) {
expect(msg).to.be(message);
expect(prev).to.eql({ state: 'red', message: '' });
expect(prev).to.eql({ state: undefined, message: 'uninitialized' });
done();
});
obj[color](message);