fix(reference)!: represent unreadable symlink targets explicitly
BREAKING CHANGE: Historical source symlinks with unreadable or unknown target_state require target: null. Placeholder target strings are rejected.
This commit is contained in:
@@ -58,7 +58,11 @@ const unavailableFileEntry = (
|
||||
...overrides,
|
||||
});
|
||||
|
||||
const symlinkEntry = (overrides: Partial<SymlinkEntry> = {}): SymlinkEntry => ({
|
||||
type KnownTargetSymlinkEntry = Extract<SymlinkEntry, { target: string }>;
|
||||
|
||||
const symlinkEntry = (
|
||||
overrides: Partial<KnownTargetSymlinkEntry> = {},
|
||||
): KnownTargetSymlinkEntry => ({
|
||||
path: "src/package.json",
|
||||
kind: "symlink",
|
||||
target: "main.ts",
|
||||
@@ -237,6 +241,50 @@ describe("historical source graph", () => {
|
||||
});
|
||||
|
||||
describe("partial historical source graphs", () => {
|
||||
it("keeps an unreadable symlink target unknown and out of root identity", () => {
|
||||
const base = graphInput();
|
||||
base.inventory_state = "partial";
|
||||
base.entries[2] = {
|
||||
path: "src/package.json",
|
||||
kind: "symlink",
|
||||
target: null,
|
||||
target_state: "unreadable",
|
||||
classifications: ["manifest"],
|
||||
limitations: ["Target could not be read."],
|
||||
};
|
||||
const graph = createHistoricalSourceGraph(base);
|
||||
expect(graph.entries[2]).toMatchObject({
|
||||
kind: "symlink",
|
||||
target: null,
|
||||
target_state: "unreadable",
|
||||
});
|
||||
|
||||
const changedMessage = structuredClone(base);
|
||||
changedMessage.entries[2] = {
|
||||
path: "src/package.json",
|
||||
kind: "symlink",
|
||||
target: null,
|
||||
target_state: "unreadable",
|
||||
classifications: ["manifest"],
|
||||
limitations: ["A different diagnostic."],
|
||||
};
|
||||
const revised = createHistoricalSourceGraph(changedMessage);
|
||||
expect(revised.root_sha256).toBe(graph.root_sha256);
|
||||
expect(computeHistoricalSourceGraphSha256(revised)).not.toBe(
|
||||
computeHistoricalSourceGraphSha256(graph),
|
||||
);
|
||||
expect(() =>
|
||||
createHistoricalSourceGraph({
|
||||
...base,
|
||||
entries: base.entries.map((entry) =>
|
||||
entry.kind === "symlink"
|
||||
? { ...entry, target: "<unreadable>" }
|
||||
: entry,
|
||||
),
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("preserves partial observations but rejects every partial complete graph", () => {
|
||||
const partial = graphInput();
|
||||
partial.inventory_state = "partial";
|
||||
|
||||
Reference in New Issue
Block a user