test(cli): reduce repeated startup and filesystem setup

This commit is contained in:
morluto
2026-10-08 04:03:24 +08:00
parent 9c3479ed95
commit d88d6c1897
19 changed files with 409 additions and 677 deletions
+7 -12
View File
@@ -9,21 +9,16 @@ import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
describe("ZIP signature detection", () => {
it.each([
[0x03, 0x04, true],
[0x05, 0x06, true],
[0x07, 0x08, true],
[0x03, 0x06, false],
[0x03, 0x08, false],
[0x05, 0x04, false],
[0x05, 0x08, false],
[0x07, 0x04, false],
[0x07, 0x06, false],
{ signature: [0x50, 0x4b, 0x05, 0x06], archive: true },
{ signature: [0x50, 0x4b, 0x03, 0x06], archive: false },
{ signature: [0x50, 0x4b, 0x03, 0x04], archive: true },
{ signature: [0x50, 0x4b, 0x07, 0x08], archive: true },
] as const)(
"classifies PK %i %i with archive signature %s",
async (third, fourth, archive) => {
"routes representative ZIP signature $signature through inventory and target parsing",
async ({ signature, archive }) => {
const root = await createTestTempDirectory("rea-zip-signature-");
const path = join(root, "input");
await writeFile(path, Buffer.from([0x50, 0x4b, third, fourth]));
await writeFile(path, Buffer.from(signature));
expect(await classifyRoot(path, false)).toBe(archive ? "zip" : "file");
const target = await parseBinaryTarget(path);
if (archive)