mirror of
https://github.com/stablyai/orca.git
synced 2026-11-01 09:37:33 +00:00
* refactor(ipc): filesystem and repo handlers are local or runtime only * test(ipc): drop two casts in the rewritten listing and import tests * fix(providers): keep the default error name so IPC callers see the old text --------- Co-authored-by: m4air <m4air@Mac.localdomain>
74 lines
2.5 KiB
TypeScript
74 lines
2.5 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
import {
|
|
clearGitCapabilityStateForTests,
|
|
getLocalGitCapabilityCache,
|
|
withLocalGitCapabilityCacheForExecution
|
|
} from './git-capability-state'
|
|
import {
|
|
resetWslLinkedWorktreeGitRoutingForTests,
|
|
seedWslLinkedWorktreeGitRoutingForTests
|
|
} from './wsl-linked-worktree-git-routing'
|
|
|
|
describe('Git capability execution-host state', () => {
|
|
beforeEach(() => {
|
|
clearGitCapabilityStateForTests()
|
|
resetWslLinkedWorktreeGitRoutingForTests()
|
|
})
|
|
|
|
it('shares native state while isolating each WSL distro', () => {
|
|
expect(getLocalGitCapabilityCache({ cwd: '/repo-a' })).toBe(
|
|
getLocalGitCapabilityCache({ cwd: '/repo-b' })
|
|
)
|
|
expect(getLocalGitCapabilityCache({ wslDistro: 'Ubuntu' })).toBe(
|
|
getLocalGitCapabilityCache({ cwd: '\\\\wsl.localhost\\Ubuntu\\home\\repo' })
|
|
)
|
|
expect(getLocalGitCapabilityCache({ wslDistro: 'Ubuntu' })).not.toBe(
|
|
getLocalGitCapabilityCache({ wslDistro: 'Debian' })
|
|
)
|
|
expect(getLocalGitCapabilityCache()).not.toBe(
|
|
getLocalGitCapabilityCache({ wslDistro: 'Ubuntu' })
|
|
)
|
|
})
|
|
|
|
it('bounds local capability entries during WSL distro churn', () => {
|
|
const first = getLocalGitCapabilityCache({ wslDistro: 'first-distro' })
|
|
first.rememberUnsupported('worktree-list-z')
|
|
for (let index = 0; index < 132; index += 1) {
|
|
getLocalGitCapabilityCache({ wslDistro: `distro-${index}` })
|
|
}
|
|
expect(
|
|
getLocalGitCapabilityCache({ wslDistro: 'first-distro' }).shouldTry('worktree-list-z')
|
|
).toBe(true)
|
|
})
|
|
|
|
it('uses native capability state for a prepared host-routed WSL worktree', async () => {
|
|
const platform = vi.spyOn(process, 'platform', 'get').mockReturnValue('win32')
|
|
try {
|
|
seedWslLinkedWorktreeGitRoutingForTests(String.raw`C:\repo\linked`)
|
|
|
|
await expect(
|
|
withLocalGitCapabilityCacheForExecution(
|
|
{ cwd: String.raw`C:\repo\linked`, wslDistro: 'Ubuntu' },
|
|
async (capabilities) => capabilities
|
|
)
|
|
).resolves.toBe(getLocalGitCapabilityCache())
|
|
expect(getLocalGitCapabilityCache()).not.toBe(
|
|
getLocalGitCapabilityCache({ wslDistro: 'Ubuntu' })
|
|
)
|
|
} finally {
|
|
platform.mockRestore()
|
|
}
|
|
})
|
|
|
|
it('starts non-candidate capability work without an added async turn', async () => {
|
|
let started = false
|
|
const result = withLocalGitCapabilityCacheForExecution({ cwd: '/repo' }, async () => {
|
|
started = true
|
|
return 'done'
|
|
})
|
|
|
|
expect(started).toBe(true)
|
|
await expect(result).resolves.toBe('done')
|
|
})
|
|
})
|