-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@W-14689540@: (Part 7) Create and set GitHub step summary markdown fr…
…om results
- Loading branch information
1 parent
4a4554b
commit 1a98eb1
Showing
14 changed files
with
6,546 additions
and
28 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
6,024 changes: 6,024 additions & 0 deletions
6,024
__tests__/data/tooManyViolations_expectedSummary.md
Large diffs are not rendered by default.
Oops, something went wrong.
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,2 @@ | ||
## Salesforce Code Analyzer Results | ||
### :white_check_mark: 0 Violations Found |
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,84 @@ | ||
import { RuntimeSummarizer, Summarizer } from '../src/summary' | ||
import { Results, ResultsFactory, RuntimeResultsFactory, RuntimeViolation, Violation } from '../src/results' | ||
import * as path from 'path' | ||
import * as fs from 'fs' | ||
import { FakeResults, FakeViolationLocation } from './fakes' | ||
|
||
describe('RuntimeSummarizer Tests', () => { | ||
const resultsFactory: ResultsFactory = new RuntimeResultsFactory() | ||
const summarizer: Summarizer = new RuntimeSummarizer() | ||
|
||
it('Test createSummaryMarkdown with sample run results', () => { | ||
const results: Results = resultsFactory.createResults( | ||
path.join('.', '__tests__', 'data', 'sampleRunResults.json'), | ||
false | ||
) | ||
const summaryMarkdown = summarizer.createSummaryMarkdown(results) | ||
|
||
const expectedSummaryMarkdown = fs.readFileSync( | ||
path.join('.', '__tests__', 'data', 'sampleRunResults_expectedSummary.md'), | ||
{ encoding: 'utf8' } | ||
) | ||
expect(summaryMarkdown).toEqual(expectedSummaryMarkdown) | ||
}) | ||
|
||
it('Test createSummaryMarkdown with sample run dfa results', () => { | ||
const results: Results = resultsFactory.createResults( | ||
path.join('.', '__tests__', 'data', 'sampleRunDfaResults.json'), | ||
true | ||
) | ||
const summaryMarkdown = summarizer.createSummaryMarkdown(results) | ||
|
||
const expectedSummaryMarkdown = fs.readFileSync( | ||
path.join('.', '__tests__', 'data', 'sampleRunDfaResults_expectedSummary.md'), | ||
{ encoding: 'utf8' } | ||
) | ||
expect(summaryMarkdown).toEqual(expectedSummaryMarkdown) | ||
}) | ||
|
||
it('Test createSummaryMarkdown with results that have no violations', () => { | ||
const results: FakeResults = new FakeResults() | ||
results.getTotalViolationCountReturnValue = 0 | ||
results.getSev1ViolationCountReturnValue = 0 | ||
results.getSev2ViolationCountReturnValue = 0 | ||
results.getSev3ViolationCountReturnValue = 0 | ||
results.getViolationsSortedBySeverityReturnValue = [] | ||
const summaryMarkdown = summarizer.createSummaryMarkdown(results) | ||
|
||
const expectedSummaryMarkdown = fs.readFileSync( | ||
path.join('.', '__tests__', 'data', 'zeroViolations_expectedSummary.md'), | ||
{ encoding: 'utf8' } | ||
) | ||
expect(summaryMarkdown).toEqual(expectedSummaryMarkdown) | ||
}) | ||
|
||
it('Test that createSummaryMarkdown trims table when too many results to fit into 1mb summary', () => { | ||
const numViolations = 12345 | ||
const results: FakeResults = new FakeResults() | ||
results.getTotalViolationCountReturnValue = numViolations | ||
results.getSev1ViolationCountReturnValue = 0 | ||
results.getSev2ViolationCountReturnValue = numViolations | ||
results.getSev3ViolationCountReturnValue = 0 | ||
results.getViolationsSortedBySeverityReturnValue = [] | ||
for (let i = 0; i < numViolations; i++) { | ||
const dummyLocation: FakeViolationLocation = new FakeViolationLocation() | ||
dummyLocation.toStringReturnValue = `/some/file.ts:${i + 1}:0` | ||
const dummyViolation: Violation = new RuntimeViolation( | ||
2, | ||
'someEngine', | ||
'someRule', | ||
undefined, | ||
`some message ${i + 1}`, | ||
dummyLocation | ||
) | ||
results.getViolationsSortedBySeverityReturnValue.push(dummyViolation) | ||
} | ||
const summaryMarkdown = summarizer.createSummaryMarkdown(results) | ||
|
||
const expectedSummaryMarkdown = fs.readFileSync( | ||
path.join('.', '__tests__', 'data', 'tooManyViolations_expectedSummary.md'), | ||
{ encoding: 'utf8' } | ||
) | ||
expect(summaryMarkdown).toEqual(expectedSummaryMarkdown) | ||
}) | ||
}) |
Oops, something went wrong.