mirror of
https://github.com/morluto/rea.git
synced 2026-10-26 17:35:11 +00:00
test(evidence): assert the exact cancellation reason after staging cleanup fails (#5601)
52d1a72af made a cancelled write whose staging cleanup also fails carry the
caller's exact abort reason as its cause, with the cancellation retained as
cleanupPrimary and the staging directory as cleanup state. The boundary test
still expected the old wrapped cause, so it failed on main and in every PR
built on it; its finally block then masked the assertion with a cleanup
error. Assert the current contract.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
dd0015aaf1
commit
85b379c4ca
1 file changed
+7
-4
@@ -208,10 +208,13 @@ it("preserves cancellation when staging cleanup also fails", async () => {
|
||||
if (result.ok) throw new Error("Expected cancellation");
|
||||
expect(result.error).toBeInstanceOf(AnalysisCancelledError);
|
||||
expect(result.error.cleanupIncomplete).toBe(true);
|
||||
expect(result.error.cause).toMatchObject({
|
||||
cause: expect.any(AnalysisCancelledError),
|
||||
owner: { directory: expect.stringContaining(".rea-write-") },
|
||||
});
|
||||
// The caller's exact abort reason stays the cause; the retained staging
|
||||
// directory is reported as cleanup state, not as the cancellation cause.
|
||||
expect(result.error.cause).toBe(controller.signal.reason);
|
||||
expect(result.error.cleanupPrimary).toBeInstanceOf(AnalysisCancelledError);
|
||||
expect(result.error.cleanupResources).toEqual([
|
||||
expect.stringContaining(".rea-write-"),
|
||||
]);
|
||||
await expect(fs.access(join(root, "cancelled.json"))).rejects.toThrow();
|
||||
const stage = requireStages(root)[0];
|
||||
if (stage !== undefined) await fs.rm(join(root, stage, "unexpected"));
|
||||
|
||||
Reference in new issue
Block a user