Skip to content

Commit

Permalink
Fix two TODOs about irregular report.json format
Browse files Browse the repository at this point in the history
These were left to minimize report.json in earlier refactoring. Fixing
them now should only affect the report.json structure but not
report.html.
  • Loading branch information
foolip committed Dec 16, 2019
1 parent d5a6085 commit f4707eb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 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]]);
});
});
4 changes: 1 addition & 3 deletions validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ async function validate() {
groupRepos[gid].push({
name: r.name,
fullName: fullName(r),
// Only include `hasRecTrack` in report.json if it's true. This is
// simply to match the original structure. TODO: include if false.
hasRecTrack: hasRecTrack ? true : undefined,
hasRecTrack,
});
}
if (repoData.ashRepo) {
Expand Down

0 comments on commit f4707eb

Please sign in to comment.