Skip to content

Commit

Permalink
Don't create a reporter if no streams were provided. Addresses #534 (#…
Browse files Browse the repository at this point in the history
…535)

* Don't create a reporter if no streams were provided. Closes #534

* Change test for no stream to assert other reporters are still created
  • Loading branch information
ianwsperber authored and arb committed Nov 21, 2016
1 parent 9d198f8 commit f957062
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ class Monitor {

internals.forOwn(this.settings.reporters, (reporterName, streamsSpec) => {

if (!streamsSpec.length) {
return;
}

const streamObjs = [];
for (let i = 0; i < streamsSpec.length; ++i) {
const spec = streamsSpec[i];
Expand Down
20 changes: 20 additions & 0 deletions test/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,26 @@ describe('Monitor', () => {

done();
});

it('does not create a reporter if the reporter has no streams', { plan: 3 }, (done) => {

const monitor = internals.monitorFactory(new Hapi.Server(), {
reporters: {
foo: [],
bar: [new GoodReporter.Incrementer(1)]
}
});

monitor.start((error) => {

expect(error).to.not.exist();

expect(monitor._reporters).to.have.length(1);
expect(monitor._reporters.bar).to.exist();

done();
});
});
});

describe('push()', () => {
Expand Down

0 comments on commit f957062

Please sign in to comment.