Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit null instead of empty object for validateAshHooks #81

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]]);
});
});