Skip to content

Commit

Permalink
Emit null instead of empty object for validateAshHooks
Browse files Browse the repository at this point in the history
This was left to minimize report.json changes in earlier
refactoring. Fixing it now should only affect the report.json
structure but not report.html.
  • Loading branch information
foolip committed Dec 16, 2019
1 parent 3f0959f commit 09522aa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 2 additions & 5 deletions lib/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,13 @@ const ashnazgHookUrls = [
];

function validateAshHooks(hooks) {
// Note: unlike `reportError` used above, here empty object literals are
// pushed instead of nulls. This is simply to match the original structure
// of report.json. TODO: change this to null, or add error details.
const errors = [];
const ashHooks = hooks.filter(h => ashnazgHookUrls.includes(h.config.url) && h.config.contentType === "json" && h.config.insecureSsl === "0" && h.config.secret !== "");
if (ashHooks.length === 0) {
errors.push(['missingashnazghook', {}]);
errors.push(['missingashnazghook', null]);
}
if (ashHooks.length > 1) {
errors.push(['duplicateashnazghooks', {}]);
errors.push(['duplicateashnazghooks', null]);
}
return errors;
}
Expand Down
4 changes: 2 additions & 2 deletions test/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ describe('validateAshHooks', () => {
it('no hooks', () => {
const hooks = [];
const errors = validateAshHooks(hooks);
assert.deepStrictEqual(errors, [['missingashnazghook', {}]]);
assert.deepStrictEqual(errors, [['missingashnazghook', null]]);
});

it('one hook', () => {
Expand Down Expand Up @@ -444,6 +444,6 @@ describe('validateAshHooks', () => {
}
}];
const errors = validateAshHooks(hooks);
assert.deepStrictEqual(errors, [['duplicateashnazghooks', {}]]);
assert.deepStrictEqual(errors, [['duplicateashnazghooks', null]]);
});
});

0 comments on commit 09522aa

Please sign in to comment.