| ... | ... | @@ -3,6 +3,7 @@ import { assert, describe, it } from "@effect/vitest"; |
| 3 | 3 | import * as Effect from "effect/Effect"; |
| 4 | 4 | import * as FileSystem from "effect/FileSystem"; |
| 5 | 5 | import * as Layer from "effect/Layer"; |
| 6 | import * as PlatformError from "effect/PlatformError"; |
| 6 | 7 | |
| 7 | 8 | import { ServerConfig } from "../config.ts"; |
| 8 | 9 | import * as GitVcsDriver from "../vcs/GitVcsDriver.ts"; |
| ... | ... | @@ -73,4 +74,27 @@ describe("ReviewService", () => { |
| 73 | 74 | assert.deepStrictEqual(detectCalls, [{ cwd: workspaceRoot }]); |
| 74 | 75 | }).pipe(Effect.provide(NodeServices.layer)), |
| 75 | 76 | ); |
| 77 | |
| 78 | it.effect("preserves unexpected path-resolution failures", () => |
| 79 | Effect.gen(function* () { |
| 80 | const fs = yield* FileSystem.FileSystem; |
| 81 | const workspaceRoot = yield* fs.makeTempDirectoryScoped({ prefix: "t3-review-workspace-" }); |
| 82 | const baseDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-review-base-" }); |
| 83 | const invalidCwd = `${workspaceRoot}\0invalid`; |
| 84 | const detectCalls: Array<{ readonly cwd: string }> = []; |
| 85 | |
| 86 | const error = yield* Effect.gen(function* () { |
| 87 | const review = yield* ReviewService.ReviewService; |
| 88 | return yield* review.getDiffPreview({ cwd: invalidCwd }).pipe(Effect.flip); |
| 89 | }).pipe(Effect.provide(makeLayer({ workspaceRoot, baseDir, detectCalls }))); |
| 90 | |
| 91 | assert.strictEqual(error._tag, "VcsRepositoryDetectionError"); |
| 92 | if (error._tag !== "VcsRepositoryDetectionError") return; |
| 93 | assert.strictEqual(error.operation, "ReviewService.assertWorkspaceBoundCwd.canonicalizePath"); |
| 94 | assert.strictEqual(error.cwd, invalidCwd); |
| 95 | assert.match(error.detail, /Failed to resolve a path/); |
| 96 | assert.instanceOf(error.cause, PlatformError.PlatformError); |
| 97 | assert.deepStrictEqual(detectCalls, []); |
| 98 | }).pipe(Effect.provide(NodeServices.layer)), |
| 99 | ); |
| 76 | 100 | }); |