fix(test): address @claude review findings for parallel staleness PR

- Add missing checkStalenessAsync mock to calltool-dispatch.test.ts
  (BLOCKER: caused 5 CI failures on every list_repos test path)
- Add async invalid-commit-hash test for symmetry with sync suite
- Document why promisified execFile omits stdio option
This commit is contained in:
azizur100389 2026-05-08 08:53:27 +01:00
parent 4ad27d9200
commit 4c74029cf7
3 changed files with 9 additions and 0 deletions

View file

@ -54,6 +54,8 @@ export async function checkStalenessAsync(
lastCommit: string,
): Promise<StalenessInfo> {
try {
// Note: promisified execFile captures stdout/stderr by default (no stdio option needed,
// unlike the sync variant which requires explicit stdio: ['pipe','pipe','pipe']).
const { stdout } = await execFileAsync('git', ['rev-list', '--count', `${lastCommit}..HEAD`], {
cwd: repoPath,
encoding: 'utf-8',

View file

@ -48,6 +48,7 @@ vi.mock('../../src/storage/repo-manager.js', () => ({
// tests don't shell out to git.
vi.mock('../../src/core/git-staleness.js', () => ({
checkStaleness: vi.fn().mockReturnValue({ isStale: false, commitsBehind: 0 }),
checkStalenessAsync: vi.fn().mockResolvedValue({ isStale: false, commitsBehind: 0 }),
checkCwdMatch: vi.fn().mockResolvedValue({ match: 'none' }),
}));

View file

@ -109,6 +109,12 @@ describe('checkStalenessAsync', () => {
expect(result.commitsBehind).toBe(0);
});
it('fails open with invalid commit hash', async () => {
const result = await checkStalenessAsync(process.cwd(), 'not-a-real-commit-hash');
expect(result.isStale).toBe(false);
expect(result.commitsBehind).toBe(0);
});
it('parallel calls complete faster than sequential', async () => {
let headCommit: string;
try {