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
This commit is contained in:
@@ -909,6 +909,27 @@ describe("the backup lock", () => {
|
|||||||
expect(existsSync(lockPath(outDir))).toBe(false);
|
expect(existsSync(lockPath(outDir))).toBe(false);
|
||||||
await lib.close();
|
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.
|
// Also serves ML data: file 100 has `ML_PAYLOAD`, the other two have none.
|
||||||
|
|||||||
Reference in New Issue
Block a user