Files
orca/src/main/git/repo-default-base-timeout.test.ts
T
Neil 7708f8e7fe perf: avoid blocking base-ref resolution (#8182)
* perf: avoid blocking base-ref resolution

* fix(git): bound async default-base probes

* fix(git): bound default-base probes during creation

* test(git): cover bounded Windows and WSL probes
2026-07-11 02:05:58 -07:00

47 lines
1.4 KiB
TypeScript

import { beforeEach, describe, expect, it, vi } from 'vitest'
const { gitExecFileAsyncMock } = vi.hoisted(() => ({
gitExecFileAsyncMock: vi.fn()
}))
vi.mock('./runner', () => ({
gitExecFileAsync: gitExecFileAsyncMock,
gitExecFileSync: vi.fn()
}))
import { getBaseRefDefault } from './repo'
describe('getBaseRefDefault async subprocess bounds', () => {
beforeEach(() => {
gitExecFileAsyncMock.mockReset()
})
it('bounds every local probe and degrades a timeout to no default', async () => {
gitExecFileAsyncMock.mockRejectedValue(new Error('git timed out.'))
await expect(getBaseRefDefault('/repo')).resolves.toBeNull()
expect(gitExecFileAsyncMock).toHaveBeenCalled()
for (const [, options] of gitExecFileAsyncMock.mock.calls) {
expect(options).toEqual({ cwd: '/repo', timeout: 15_000 })
}
})
it('preserves the same timeout when routing probes through WSL', async () => {
gitExecFileAsyncMock.mockRejectedValue(new Error('git timed out.'))
await expect(
getBaseRefDefault('\\\\wsl.localhost\\Ubuntu\\repo', { wslDistro: 'Ubuntu' })
).resolves.toBeNull()
expect(gitExecFileAsyncMock).toHaveBeenCalled()
for (const [, options] of gitExecFileAsyncMock.mock.calls) {
expect(options).toEqual({
cwd: '\\\\wsl.localhost\\Ubuntu\\repo',
timeout: 15_000,
wslDistro: 'Ubuntu'
})
}
})
})