Skip to content

Commit 22c582b

Browse files
Copilotdata-douser
andauthored
Extract zero-results SARIF fixture into helper function
Address code review feedback: extract inline SARIF object into createZeroResultsSarif() helper for consistency with existing patterns. Agent-Logs-Url: https://github.com/advanced-security/codeql-development-mcp-server/sessions/7ea1caeb-de6d-40cd-b045-3dd634602403 Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
1 parent 1f34157 commit 22c582b

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

server/test/src/tools/sarif-tools.test.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,25 @@ function createTestSarif() {
7070
};
7171
}
7272

73+
/** SARIF with a defined rule but zero results — validates resultCount: 0 */
74+
function createZeroResultsSarif() {
75+
return {
76+
version: '2.1.0',
77+
runs: [{
78+
tool: {
79+
driver: {
80+
name: 'CodeQL',
81+
version: '2.25.1',
82+
rules: [
83+
{ id: 'js/unused-variable', shortDescription: { text: 'Unused variable' } },
84+
],
85+
},
86+
},
87+
results: [],
88+
}],
89+
};
90+
}
91+
7392
// ---------------------------------------------------------------------------
7493
// Tests
7594
// ---------------------------------------------------------------------------
@@ -231,23 +250,8 @@ describe('SARIF Tools', () => {
231250
});
232251

233252
it('should return resultCount 0 for rules with no results', async () => {
234-
const noResultsSarif = {
235-
version: '2.1.0',
236-
runs: [{
237-
tool: {
238-
driver: {
239-
name: 'CodeQL',
240-
version: '2.25.1',
241-
rules: [
242-
{ id: 'js/unused-variable', shortDescription: { text: 'Unused variable' } },
243-
],
244-
},
245-
},
246-
results: [],
247-
}],
248-
};
249253
const noResultsPath = join(testStorageDir, 'no-results.sarif');
250-
writeFileSync(noResultsPath, JSON.stringify(noResultsSarif));
254+
writeFileSync(noResultsPath, JSON.stringify(createZeroResultsSarif()));
251255

252256
const result = await handlers.sarif_list_rules({ sarifPath: noResultsPath });
253257
const parsed = JSON.parse(result.content[0].text);

0 commit comments

Comments
 (0)