Skip to content

Commit

Permalink
fix: uses explicit validation result sections list for logging output
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-zakharchenko committed May 21, 2019
1 parent 3065284 commit a2b8a0a
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/TransactionRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,15 +573,18 @@ include a message body: https://tools.ietf.org/html/rfc7231#section-6.3\
let message = '';
const object = gavelResult || {};
let validatorOutput;
for (const sectionName of Object.keys(object || {})) {
// Section names are 'statusCode', 'headers', 'body' (and 'version', which is irrelevant)

// Order-sensitive list of validation sections to output in the log
const resultSections = ['headers', 'body', 'statusCode']
.filter(sectionName => Object.prototype.hasOwnProperty.call(object, sectionName));

resultSections.forEach((sectionName) => {
validatorOutput = object[sectionName];
if (sectionName !== 'version') {
for (const gavelError of validatorOutput.results || []) {
message += `${sectionName}: ${gavelError.message}\n`;
}
}
}
(validatorOutput.results || []).forEach((gavelError) => {
message += `${sectionName}: ${gavelError.message}\n`;
});
});

test.message = message;

// Record raw validation output to transaction results object
Expand Down

0 comments on commit a2b8a0a

Please sign in to comment.