mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 17:17:38 +00:00
test(git): keep mocked worktree roots present for Git cases
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import type * as LocalWorktreeFilesystem from '../local-worktree-filesystem'
|
||||
import type * as FsPromises from 'node:fs/promises'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi, type MockInstance } from 'vitest'
|
||||
|
||||
@@ -17,6 +18,13 @@ const {
|
||||
resolveGitDirMock: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('../local-worktree-filesystem', async () => {
|
||||
const actual = await vi.importActual<typeof LocalWorktreeFilesystem>(
|
||||
'../local-worktree-filesystem'
|
||||
)
|
||||
return { ...actual, isLocalWorktreePathMissing: vi.fn().mockResolvedValue(false) }
|
||||
})
|
||||
|
||||
vi.mock('./runner', () => ({
|
||||
gitExecFileAsync: gitExecFileAsyncMock,
|
||||
gitExecFileSync: gitExecFileSyncMock,
|
||||
|
||||
@@ -3,6 +3,7 @@ vi.mock('../../shared/git-worktree-admin', () => ({
|
||||
isBranchReservedByWorktreeOperation: vi.fn().mockResolvedValue(false)
|
||||
}))
|
||||
|
||||
import type * as LocalWorktreeFilesystem from '../local-worktree-filesystem'
|
||||
import type * as FsPromises from 'node:fs/promises'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi, type MockInstance } from 'vitest'
|
||||
|
||||
@@ -22,6 +23,13 @@ const {
|
||||
resolveGitDirMock: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('../local-worktree-filesystem', async () => {
|
||||
const actual = await vi.importActual<typeof LocalWorktreeFilesystem>(
|
||||
'../local-worktree-filesystem'
|
||||
)
|
||||
return { ...actual, isLocalWorktreePathMissing: vi.fn().mockResolvedValue(false) }
|
||||
})
|
||||
|
||||
vi.mock('./runner', () => ({
|
||||
gitExecFileAsync: gitExecFileAsyncMock,
|
||||
gitExecFileSync: gitExecFileSyncMock,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type * as LocalWorktreeFilesystem from '../local-worktree-filesystem'
|
||||
import { existsSync } from 'node:fs'
|
||||
import type * as FsPromises from 'node:fs/promises'
|
||||
import { mkdir, mkdtemp, rm } from 'node:fs/promises'
|
||||
@@ -21,6 +22,13 @@ const {
|
||||
resolveGitDirMock: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('../local-worktree-filesystem', async () => {
|
||||
const actual = await vi.importActual<typeof LocalWorktreeFilesystem>(
|
||||
'../local-worktree-filesystem'
|
||||
)
|
||||
return { ...actual, isLocalWorktreePathMissing: vi.fn().mockResolvedValue(false) }
|
||||
})
|
||||
|
||||
vi.mock('./runner', () => ({
|
||||
gitExecFileAsync: gitExecFileAsyncMock,
|
||||
gitExecFileSync: gitExecFileSyncMock,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// addWorktree: checkout creation, branch-base/push.autoSetupRemote config writes, ref qualification.
|
||||
import type * as LocalWorktreeFilesystem from '../local-worktree-filesystem'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi, type MockInstance } from 'vitest'
|
||||
|
||||
const { gitExecFileAsyncMock, gitExecFileSyncMock, translateWslOutputPathsMock } = vi.hoisted(
|
||||
@@ -9,6 +10,13 @@ const { gitExecFileAsyncMock, gitExecFileSyncMock, translateWslOutputPathsMock }
|
||||
})
|
||||
)
|
||||
|
||||
vi.mock('../local-worktree-filesystem', async () => {
|
||||
const actual = await vi.importActual<typeof LocalWorktreeFilesystem>(
|
||||
'../local-worktree-filesystem'
|
||||
)
|
||||
return { ...actual, isLocalWorktreePathMissing: vi.fn().mockResolvedValue(false) }
|
||||
})
|
||||
|
||||
vi.mock('./runner', () => ({
|
||||
gitExecFileAsync: gitExecFileAsyncMock,
|
||||
gitExecFileSync: gitExecFileSyncMock,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type * as LocalWorktreeFilesystem from '../local-worktree-filesystem'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import type * as WorktreePreparationLock from './worktree-preparation-lock'
|
||||
|
||||
@@ -8,6 +9,13 @@ type GitExec = (
|
||||
|
||||
const gitExecFileAsyncMock = vi.hoisted(() => vi.fn<GitExec>())
|
||||
|
||||
vi.mock('../local-worktree-filesystem', async () => {
|
||||
const actual = await vi.importActual<typeof LocalWorktreeFilesystem>(
|
||||
'../local-worktree-filesystem'
|
||||
)
|
||||
return { ...actual, isLocalWorktreePathMissing: vi.fn().mockResolvedValue(false) }
|
||||
})
|
||||
|
||||
vi.mock('./runner', () => ({ gitExecFileAsync: gitExecFileAsyncMock }))
|
||||
vi.mock('./worktree-preparation-lock', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof WorktreePreparationLock>()),
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
import type * as LocalWorktreeFilesystem from '../local-worktree-filesystem'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const { gitExecFileAsyncMock } = vi.hoisted(() => ({
|
||||
gitExecFileAsyncMock: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('../local-worktree-filesystem', async () => {
|
||||
const actual = await vi.importActual<typeof LocalWorktreeFilesystem>(
|
||||
'../local-worktree-filesystem'
|
||||
)
|
||||
return { ...actual, isLocalWorktreePathMissing: vi.fn().mockResolvedValue(false) }
|
||||
})
|
||||
|
||||
vi.mock('./runner', () => ({
|
||||
gitExecFileAsync: gitExecFileAsyncMock,
|
||||
gitExecFileSync: vi.fn(),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// listWorktreeGraph: -z porcelain listing plus the older-Git usage-error fallback.
|
||||
import type * as LocalWorktreeFilesystem from '../local-worktree-filesystem'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const { gitExecFileAsyncMock, gitExecFileSyncMock, translateWslOutputPathsMock } = vi.hoisted(
|
||||
@@ -13,6 +14,13 @@ vi.mock('../../shared/git-worktree-admin', () => ({
|
||||
annotateWorktreeLocksFromAdmin: async (_repoPath: string, rows: unknown[]) => rows
|
||||
}))
|
||||
|
||||
vi.mock('../local-worktree-filesystem', async () => {
|
||||
const actual = await vi.importActual<typeof LocalWorktreeFilesystem>(
|
||||
'../local-worktree-filesystem'
|
||||
)
|
||||
return { ...actual, isLocalWorktreePathMissing: vi.fn().mockResolvedValue(false) }
|
||||
})
|
||||
|
||||
vi.mock('./runner', () => ({
|
||||
gitExecFileAsync: gitExecFileAsyncMock,
|
||||
gitExecFileSync: gitExecFileSyncMock,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type * as LocalWorktreeFilesystem from '../local-worktree-filesystem'
|
||||
import type * as FsPromises from 'node:fs/promises'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
@@ -21,6 +22,13 @@ vi.mock('../../shared/git-worktree-admin', () => ({
|
||||
annotateWorktreeLocksFromAdmin: async (_repoPath: string, rows: unknown[]) => rows
|
||||
}))
|
||||
|
||||
vi.mock('../local-worktree-filesystem', async () => {
|
||||
const actual = await vi.importActual<typeof LocalWorktreeFilesystem>(
|
||||
'../local-worktree-filesystem'
|
||||
)
|
||||
return { ...actual, isLocalWorktreePathMissing: vi.fn().mockResolvedValue(false) }
|
||||
})
|
||||
|
||||
vi.mock('./runner', () => ({
|
||||
gitExecFileAsync: gitExecFileAsyncMock,
|
||||
gitExecFileSync: gitExecFileSyncMock,
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
* production `listWorktreesStrict` always runs the listing through it, so the paths that reach the
|
||||
* comparison are UNC, never Linux. The end-to-end case below therefore drives the real translator.
|
||||
*/
|
||||
import type * as LocalWorktreeFilesystem from '../local-worktree-filesystem'
|
||||
import type * as FsPromises from 'node:fs/promises'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import type * as WslPathTranslation from './command-runner/wsl-path-translation'
|
||||
@@ -23,6 +24,13 @@ const { gitExecFileAsyncMock, gitExecFileSyncMock, statMock, readFileMock, resol
|
||||
|
||||
// Why the real translator: an identity mock removes the Linux -> UNC rewrite that production
|
||||
// always applies, which is the only reason the Linux spelling would ever reach the comparison.
|
||||
vi.mock('../local-worktree-filesystem', async () => {
|
||||
const actual = await vi.importActual<typeof LocalWorktreeFilesystem>(
|
||||
'../local-worktree-filesystem'
|
||||
)
|
||||
return { ...actual, isLocalWorktreePathMissing: vi.fn().mockResolvedValue(false) }
|
||||
})
|
||||
|
||||
vi.mock('./runner', async () => {
|
||||
const translation = await vi.importActual<typeof WslPathTranslation>(
|
||||
'./command-runner/wsl-path-translation'
|
||||
|
||||
Reference in New Issue
Block a user