(
tempDir: string,
service: ProjectService,
input: { testCaseId: string; repoUrl: string; cloneParentDir: string; sshAuthSock?: string }
)
| 70 | } |
| 71 | |
| 72 | async function cloneWithFakeGit( |
| 73 | tempDir: string, |
| 74 | service: ProjectService, |
| 75 | input: { testCaseId: string; repoUrl: string; cloneParentDir: string; sshAuthSock?: string } |
| 76 | ) { |
| 77 | if (process.platform === "win32") { |
| 78 | // These tests rely on a POSIX shell shim named "git" in PATH. |
| 79 | return null; |
| 80 | } |
| 81 | |
| 82 | const fakeBinDir = path.join(tempDir, `fake-bin-${input.testCaseId}`); |
| 83 | const fakeGitArgsLogPath = path.join(tempDir, `fake-git-${input.testCaseId}-args.log`); |
| 84 | await fs.mkdir(fakeBinDir, { recursive: true }); |
| 85 | await writeFakeGitCloneShim(path.join(fakeBinDir, "git")); |
| 86 | |
| 87 | const result = await withEnv( |
| 88 | { |
| 89 | PATH: `${fakeBinDir}${path.delimiter}${process.env.PATH ?? ""}`, |
| 90 | FAKE_GIT_ARGS_LOG: fakeGitArgsLogPath, |
| 91 | HOME: tempDir, |
| 92 | SSH_AUTH_SOCK: input.sshAuthSock, |
| 93 | }, |
| 94 | () => service.clone({ repoUrl: input.repoUrl, cloneParentDir: input.cloneParentDir }) |
| 95 | ); |
| 96 | |
| 97 | expect(result.success).toBe(true); |
| 98 | if (!result.success) throw new Error("Expected success"); |
| 99 | const loggedArgs = (await fs.readFile(fakeGitArgsLogPath, "utf-8")).trim().split("\n"); |
| 100 | return { result, loggedArgs, cloneWorkPath: loggedArgs[4] ?? "" }; |
| 101 | } |
| 102 | |
| 103 | describe("ProjectService", () => { |
| 104 | let tempDir: string; |
no test coverage detected