From 4dc9e9e23cc73f1f5257e99146c9dcc2aec337b9 Mon Sep 17 00:00:00 2001 From: sneak Date: Wed, 14 Oct 2026 05:18:34 +0000 Subject: [PATCH] Test: runBackup rejects a contentConcurrency that is not a positive integer runBackup takes a library object from its caller. One whose contentConcurrency is missing, 0 or negative starts no worker, so the backup stores no original and reports no error. The test expects runBackup to reject any limit that is not a positive integer, as BoundedPool does, before it takes the lock, which would create the download directory. Today it takes the lock and fails on the first method the object lacks. Model: opus-5-5 --- test/cli/backup.test.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/cli/backup.test.ts b/test/cli/backup.test.ts index 7330b72..1938a4b 100644 --- a/test/cli/backup.test.ts +++ b/test/cli/backup.test.ts @@ -909,6 +909,27 @@ describe("the backup lock", () => { expect(existsSync(lockPath(outDir))).toBe(false); await lib.close(); }); + + // `runBackup` takes a library object from its caller. With a + // `contentConcurrency` below 1, or one that is not a number, it would + // back up no original and report no error. It rejects any that is not a + // positive integer, as `BoundedPool` does, before it takes the lock, + // which would create the download directory, and before it asks the + // library for anything: the object here has nothing else. + it("rejects a library whose contentConcurrency is not a positive integer, before taking the lock", async () => { + const outDir = join(root, "backup"); + for (const contentConcurrency of [undefined, 0, -1, 1.5, NaN]) { + const lib = { contentConcurrency } as unknown as BackupLibrary; + + await expect( + runBackup(lib, { downloadDirectory: outDir }), + ).rejects.toThrow( + `contentConcurrency must be a positive integer, got ${contentConcurrency}`, + ); + + expect(existsSync(outDir)).toBe(false); + } + }); }); // Also serves ML data: file 100 has `ML_PAYLOAD`, the other two have none.