Files
reverse-engineering-anything/src/artifacts/pyinstaller/PyInstallerFileAdmission.test.ts
T
MeskineMorty 49bb6c84b0 fix(pyinstaller): report changed admission as integrity (#6325)
Map RegularFileChangedError from reader admission to an integrity failure instead of the generic I/O and archive-open diagnostic. This preserves the changed-source condition and the existing stable-artifact recovery guidance.
2026-10-23 01:38:22 +08:00

34 lines
1.1 KiB
TypeScript

import { expect, it, vi } from "vitest";
import {
openRegularFile,
RegularFileChangedError,
} from "../../filesystem/RegularFile.js";
import { PyInstallerArtifactReader } from "../PyInstallerArtifactReader.js";
vi.mock("../../filesystem/RegularFile.js", async (importOriginal) => {
const actual =
await importOriginal<typeof import("../../filesystem/RegularFile.js")>();
return { ...actual, openRegularFile: vi.fn(actual.openRegularFile) };
});
it("classifies a source replacement during admission as an integrity failure", async () => {
const path = "/selected/app";
const changed = new RegularFileChangedError(path);
vi.mocked(openRegularFile).mockRejectedValueOnce(changed);
const reader = new PyInstallerArtifactReader(path);
try {
await expect(reader.prepareContainer("0".repeat(64))).rejects.toMatchObject(
{
reason: "integrity",
message: `PyInstaller source changed during admission: ${path}`,
},
);
expect(openRegularFile).toHaveBeenCalledWith(path, {
symlinks: "reject",
signal: expect.any(AbortSignal),
});
} finally {
await reader.close();
}
});