Files
reverse-engineering-anything/src/native/AppleDispatchMetadata.failure.test.ts
T
morluto 6fa58b0ec8 feat(artifacts): require every integrity reader failure to name its check (#11505)
ArtifactReaderFailure overloads require integrityCheck for a literal
"integrity" reason and an explicit (possibly undefined) check for a rebuild
whose reason is not a literal; primaryFacts always carries it. The .NET bundle
reader uses assertProducedEntry, and the PyInstaller cookie probe and owned
lease cleanup rewrap keep the check they previously dropped.
2026-11-16 08:10:08 +08:00

55 lines
2.0 KiB
TypeScript

import { expect, it } from "vitest";
import { ArtifactReaderFailure } from "../resources/ArtifactReader.js";
import { appleDispatchMetadataFailure } from "./AppleDispatchMetadata.js";
import { BinaryFormatFailure } from "../domain/binaryContainer.js";
it.each(["malformed", "unsupported"] as const)(
"keeps an explicit %s metadata refusal target-specific",
(kind) => {
const cause = new BinaryFormatFailure(kind, "metadata format refused");
expect(appleDispatchMetadataFailure(cause, "/selected")).toMatchObject({
_tag: "AnalysisUnsupportedTargetError",
path: "/selected",
reason: "metadata format refused",
});
},
);
it.each([new RangeError("unexpected range"), new TypeError("unexpected type")])(
"keeps an unclassified parser exception as a provider failure (%s)",
(cause) => {
expect(appleDispatchMetadataFailure(cause, "/selected")._tag).toBe(
"ProviderAdapterError",
);
},
);
// The metadata target is already bound, so losing it is a change to that artifact rather than a new input error.
it.each(["integrity", "path"] as const)(
"reports a %s source-read refusal as a change to the bound target, not a provider failure",
(reason) => {
const cause = new ArtifactReaderFailure(reason, "source boundary refused", {
integrityCheck: reason === "integrity" ? "container-identity" : undefined,
});
expect(appleDispatchMetadataFailure(cause, "/selected")._tag).toBe(
"AnalysisArtifactChangedError",
);
},
);
it.each(["EACCES", "EPERM", "ENOENT"])(
"preserves the filesystem outcome %s for a bound metadata target",
(code) => {
const physical = Object.assign(new Error("selected read refused"), {
code,
});
const cause = new ArtifactReaderFailure("io", "could not read", {
cause: physical,
});
expect(appleDispatchMetadataFailure(cause, "/selected")._tag).toBe(
code === "ENOENT"
? "AnalysisArtifactChangedError"
: "AnalysisAccessDeniedError",
);
},
);