-
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.
- Report skipped tests for JUnit & Go test formats - Generate a JUnit badge only if at least one file matches - Improve tests, types and naming
- Loading branch information
1 parent
a3b1d30
commit f37294d
Showing
25 changed files
with
190 additions
and
111 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
/** | ||
* Build a tests badge. | ||
* @param {*} data Badge data | ||
* @returns {import('./index.js').Badge} Badge content | ||
* @param {TestReportData} data Test report data | ||
* @returns {BadgeContent} Badge content | ||
*/ | ||
export function buildBadge(data) { | ||
const content = {}; | ||
content.message = `${data.passed} passed`; | ||
content.color = data.passed > 0 ? 'brightgreen' : 'lightgrey'; | ||
if (data.failed > 0) { | ||
content.message += `, ${data.failed} failed`; | ||
content.color = 'red'; | ||
} | ||
if (data.skipped > 0) { | ||
content.message += `, ${data.skipped} skipped`; | ||
} | ||
content.color = data.failed === 0 ? 'brightgreen' : 'red'; | ||
return content; | ||
} |
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 |
---|---|---|
@@ -1,16 +1,37 @@ | ||
import assert from 'assert/strict'; | ||
import { copyFile, mkdir, rm, writeFile } from 'fs/promises'; | ||
import { join } from 'path'; | ||
import { getReports } from './go.js'; | ||
|
||
describe('reports/go', () => { | ||
describe('#getReports()', () => { | ||
it('should return tests and coverage reports', async () => { | ||
const reports = await getReports(join(process.cwd(), 'test/data/go')); | ||
assert.equal(reports.length, 2); | ||
assert.deepEqual(reports, [ | ||
{ type: 'tests', data: { passed: 3, failed: 0, tests: 3 } }, | ||
{ type: 'coverage', data: { coverage: 96.5 } } | ||
]); | ||
before(async () => { | ||
await mkdir('test/data/go/project'); | ||
await writeFile('test/data/go/project/go.mod', ''); | ||
}); | ||
const coverage = { type: 'coverage', data: { coverage: 96.5 } }; | ||
const tests = [ | ||
{ file: 'test.out', expected: [{ type: 'tests', data: { tests: 3, passed: 3, failed: 0, skipped: 0 } }, coverage] }, | ||
{ file: 'only-test.out', expected: [{ type: 'tests', data: { tests: 2, passed: 2, failed: 0, skipped: 0 } }] }, | ||
{ file: 'failed-test.out', expected: [{ type: 'tests', data: { tests: 6, passed: 3, failed: 2, skipped: 1 } }, coverage] }, | ||
{ file: 'go.mod', expected: [] } | ||
]; | ||
for (const { file, expected } of tests) { | ||
it(`should return expected report(s) for file ${file}`, async () => { | ||
await copyFile(join('test/data/go', file), 'test/data/go/project/test.out'); | ||
const reports = await getReports(join(process.cwd(), 'test/data/go/project')); | ||
assert.equal(reports.length, expected.length); | ||
assert.deepEqual(reports, expected); | ||
}); | ||
} | ||
after(async () => { | ||
await rm('test/data/go/project', { recursive: true }); | ||
}); | ||
|
||
it('should not return any report when the go.mod file is missing', async () => { | ||
const reports = await getReports(join(process.cwd(), 'test/data/junit')); | ||
assert.equal(reports.length, 0); | ||
assert.deepEqual(reports, []); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.