-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(cli): add assertions for not containing negative summaries (#3237)
- Loading branch information
1 parent
046418f
commit c3245a5
Showing
16 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const _checkSummaries = (t, summaries, type) => { | ||
for (const summaryMetric of Object.keys(summaries)) { | ||
for (const aggregation of Object.keys(summaries[summaryMetric])) { | ||
if ( | ||
summaries[summaryMetric][aggregation] < 0 || | ||
summaries[summaryMetric][aggregation] === null | ||
) { | ||
t.fail( | ||
`Found invalid value in ${type} summaries: ${summaryMetric}.${aggregation} = ${summaries[summaryMetric][aggregation]}` | ||
); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
const checkForNegativeValues = (t, report) => { | ||
const aggregateSummaries = report.aggregate?.summaries; | ||
|
||
if (!aggregateSummaries || Object.keys(aggregateSummaries).length === 0) { | ||
t.fail('No aggregate summaries found in the report'); | ||
} | ||
|
||
_checkSummaries(t, aggregateSummaries, 'aggregate'); | ||
|
||
if (!report.intermediate || report.intermediate.length === 0) { | ||
t.fail('No intermediate summaries found in the report'); | ||
} | ||
|
||
for (const intermediate of report.intermediate) { | ||
const intermediateSummaries = intermediate.summaries; | ||
if ( | ||
!intermediateSummaries || | ||
Object.keys(intermediateSummaries).length === 0 | ||
) { | ||
continue; | ||
} | ||
_checkSummaries(t, intermediateSummaries, 'intermediate'); | ||
} | ||
}; | ||
|
||
module.exports = { | ||
checkForNegativeValues | ||
}; |