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.