From 0a52fd17a3dde61ca3b9b40545b97e8deee40d7f Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 9 May 2026 02:20:58 +0100 Subject: [PATCH] test: dedupe session disk budget absence assertions --- src/config/sessions/disk-budget.test.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/config/sessions/disk-budget.test.ts b/src/config/sessions/disk-budget.test.ts index 8902bfc0b1d..1b086f495bd 100644 --- a/src/config/sessions/disk-budget.test.ts +++ b/src/config/sessions/disk-budget.test.ts @@ -14,6 +14,10 @@ async function expectPathExists(targetPath: string): Promise { await expect(fs.access(targetPath)).resolves.toBeUndefined(); } +async function expectPathMissing(targetPath: string): Promise { + await expect(fs.stat(targetPath)).rejects.toMatchObject({ code: "ENOENT" }); +} + describe("enforceSessionDiskBudget", () => { it("does not treat referenced transcripts with marker-like session IDs as archived artifacts", async () => { await withTempDir({ prefix: "openclaw-disk-budget-" }, async (dir) => { @@ -80,7 +84,7 @@ describe("enforceSessionDiskBudget", () => { }); await expectPathExists(transcriptPath); - await expect(fs.stat(archivePath)).rejects.toThrow(); + await expectPathMissing(archivePath); expect(result).toEqual( expect.objectContaining({ removedFiles: 1, @@ -140,7 +144,7 @@ describe("enforceSessionDiskBudget", () => { }); await expectPathExists(transcriptPath); - await expect(fs.stat(checkpointPath)).rejects.toThrow(); + await expectPathMissing(checkpointPath); await expectPathExists(referencedCheckpointPath); expect(result).toEqual( expect.objectContaining({ @@ -190,8 +194,8 @@ describe("enforceSessionDiskBudget", () => { await expectPathExists(transcriptPath); await expectPathExists(referencedRuntime); await expectPathExists(referencedPointer); - await expect(fs.stat(orphanRuntime)).rejects.toThrow(); - await expect(fs.stat(orphanPointer)).rejects.toThrow(); + await expectPathMissing(orphanRuntime); + await expectPathMissing(orphanPointer); expect(result).toEqual( expect.objectContaining({ removedFiles: 2,