Skip to content

Commit 5189159

Browse files
committed
Add test for modified findSarifFilesInDir
1 parent f7fbaa0 commit 5189159

File tree

6 files changed

+34
-10
lines changed

6 files changed

+34
-10
lines changed

lib/upload-lib.js

Lines changed: 8 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-lib.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-lib.test.js

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-lib.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/upload-lib.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ test("finding SARIF files", async (t) => {
122122
"file",
123123
);
124124

125+
// add some `.quality.sarif` files that should be ignored, unless we look for them specifically
126+
fs.writeFileSync(path.join(tmpDir, "a.quality.sarif"), "");
127+
fs.writeFileSync(path.join(tmpDir, "dir1", "b.quality.sarif"), "");
128+
125129
const sarifFiles = uploadLib.findSarifFilesInDir(tmpDir);
126130

127131
t.deepEqual(sarifFiles, [
@@ -130,6 +134,16 @@ test("finding SARIF files", async (t) => {
130134
path.join(tmpDir, "dir1", "d.sarif"),
131135
path.join(tmpDir, "dir1", "dir2", "e.sarif"),
132136
]);
137+
138+
const qualitySarifFiles = uploadLib.findSarifFilesInDir(
139+
tmpDir,
140+
uploadLib.qualityIsSarif,
141+
);
142+
143+
t.deepEqual(qualitySarifFiles, [
144+
path.join(tmpDir, "a.quality.sarif"),
145+
path.join(tmpDir, "dir1", "b.quality.sarif"),
146+
]);
133147
});
134148
});
135149

src/upload-lib.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,8 @@ export interface UploadResult {
380380
sarifID: string;
381381
}
382382

383-
const qualityIsSarif = (name: string) => name.endsWith(".quality.sarif");
384-
const defaultIsSarif = (name: string) =>
383+
export const qualityIsSarif = (name: string) => name.endsWith(".quality.sarif");
384+
export const defaultIsSarif = (name: string) =>
385385
name.endsWith(".sarif") && !qualityIsSarif(name);
386386

387387
// Recursively walks a directory and returns all SARIF files it finds.

0 commit comments

Comments
 (0)