|
1 | 1 | import { describe, expect, it } from "@effect/vitest"; |
2 | | -import { ProjectId, SourceControlRepositoryError } from "@t3tools/contracts"; |
| 2 | +import { |
| 3 | + OrchestrationDispatchCommandError, |
| 4 | + ProjectId, |
| 5 | + SourceControlRepositoryError, |
| 6 | +} from "@t3tools/contracts"; |
3 | 7 | import * as Deferred from "effect/Deferred"; |
4 | 8 | import * as Effect from "effect/Effect"; |
5 | 9 | import * as Fiber from "effect/Fiber"; |
@@ -223,6 +227,25 @@ describe("ProjectCloneTracker", () => { |
223 | 227 | }).pipe(Effect.provide(harness.layer)); |
224 | 228 | }); |
225 | 229 |
|
| 230 | + it.effect("releases the claim when project creation fails", () => { |
| 231 | + const harness = makeHarness(); |
| 232 | + const hooks: ProjectCloneTracker.ProjectCloneHooks = { |
| 233 | + ...harness.hooks, |
| 234 | + createProject: () => |
| 235 | + Effect.fail(new OrchestrationDispatchCommandError({ message: "workspace root exists" })), |
| 236 | + }; |
| 237 | + return Effect.gen(function* () { |
| 238 | + const tracker = yield* ProjectCloneTracker.ProjectCloneTracker; |
| 239 | + const error = yield* Effect.flip(tracker.start(startInput, hooks)); |
| 240 | + expect(error.message).toContain("workspace root exists"); |
| 241 | + expect(yield* tracker.get(projectId)).toBeNull(); |
| 242 | + // The destination is free again for a corrected attempt. |
| 243 | + yield* tracker.start(startInput, harness.hooks); |
| 244 | + yield* Effect.yieldNow; |
| 245 | + expect((yield* tracker.get(projectId))?.phase).toBe("done"); |
| 246 | + }).pipe(Effect.provide(harness.layer)); |
| 247 | + }); |
| 248 | + |
226 | 249 | it.effect("does not create a project when the clone cannot be prepared", () => { |
227 | 250 | const harness = makeHarness(); |
228 | 251 | const layer = ProjectCloneTracker.layer.pipe( |
|
0 commit comments