more tests for log and Node

This commit is contained in:
dceejay 2015-03-08 16:53:48 +00:00
parent 10277aa956
commit 9c46feb22b
2 changed files with 23 additions and 0 deletions

View File

@ -49,6 +49,17 @@ describe("red/log", function() {
sinon.assert.calledWithMatch(util.log,"");
});
it('it can raise a metric', function() {
var metrics = {};
metrics.level = log.METRIC;
metrics.nodeid = "testid";
metrics.event = "node.test.testevent";
metrics.msgid = "12345";
metrics.value = "the metric payload";
var ret = log.log(metrics);
sinon.assert.calledWithMatch(util.log,"");
});
it('it checks metrics are enabled', function() {
log.metric().should.equal(true);
var sett = {logging: { console: { level: 'info', metrics: false } } };

View File

@ -483,6 +483,18 @@ describe('Node', function() {
Log.log.restore();
done();
});
it('returns not defined if eventname defined', function(done) {
var n = new RedNode({id:'123',type:'abc'});
var loginfo = {};
sinon.stub(Log, 'log', function(msg) {
loginfo = msg;
});
var msg = {payload:"foo", _msgid:"987654321"};
var m = n.metric("info",msg,"15mb");
should(m).be.undefined;
Log.log.restore();
done();
});
});
describe('#status', function() {