mirror of
https://github.com/morluto/rea.git
synced 2026-12-06 15:33:56 +08:00
test(artifact): share path change expectations (#17375)
This commit is contained in:
@@ -32,6 +32,17 @@ const changedDimensions = (...dimensions: string[]) => ({
|
||||
changes: [{ classification: "changed", dimensions }],
|
||||
});
|
||||
|
||||
const expectedPathChange = (
|
||||
logicalPath: string,
|
||||
classification: string,
|
||||
dimension: string,
|
||||
) =>
|
||||
expect.objectContaining({
|
||||
logical_path: logicalPath,
|
||||
classification,
|
||||
dimensions: [dimension],
|
||||
});
|
||||
|
||||
const inventoryCarrier = (inventory: ArtifactInventoryResult) =>
|
||||
observedFileInventoryEvidence(inventory, "packing-observation");
|
||||
|
||||
@@ -173,11 +184,7 @@ it.each(["left", "right"] as const)(
|
||||
status: "truncated",
|
||||
summary: { changed: 0 },
|
||||
changes: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
logical_path: "one.js",
|
||||
classification: "unknown",
|
||||
dimensions: ["availability"],
|
||||
}),
|
||||
expectedPathChange("one.js", "unknown", "availability"),
|
||||
]),
|
||||
});
|
||||
expect(compareArtifacts(evidence, evidence)).toMatchObject({
|
||||
@@ -219,11 +226,7 @@ it("does not infer a relation change when a retained edge's logical parent is om
|
||||
status: "truncated",
|
||||
summary: { changed: 0 },
|
||||
changes: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
logical_path: "one.js",
|
||||
classification: "unknown",
|
||||
dimensions: ["availability"],
|
||||
}),
|
||||
expectedPathChange("one.js", "unknown", "availability"),
|
||||
]),
|
||||
});
|
||||
});
|
||||
@@ -246,11 +249,7 @@ it("compares complete relations when an unrelated node is omitted", () => {
|
||||
expect(result).toMatchObject({
|
||||
status: "truncated",
|
||||
changes: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
logical_path: "one.js",
|
||||
classification: "changed",
|
||||
dimensions: ["relations"],
|
||||
}),
|
||||
expectedPathChange("one.js", "changed", "relations"),
|
||||
]),
|
||||
});
|
||||
});
|
||||
@@ -1005,13 +1004,7 @@ it("compares a node-less record of any compared kind by its declaration", () =>
|
||||
recordObservation(espImageSegment),
|
||||
recordObservation(movedSegment),
|
||||
).changes,
|
||||
).toEqual([
|
||||
expect.objectContaining({
|
||||
logical_path: "record",
|
||||
classification: "changed",
|
||||
dimensions: ["metadata"],
|
||||
}),
|
||||
]);
|
||||
).toEqual([expectedPathChange("record", "changed", "metadata")]);
|
||||
});
|
||||
|
||||
it("compares node-less records by declaration and keeps content changes", () => {
|
||||
@@ -1026,26 +1019,14 @@ it("compares node-less records by declaration and keeps content changes", () =>
|
||||
recordObservation(runtimeOption),
|
||||
recordObservation({ ...runtimeOption, source_name: "pyi-python-flag O" }),
|
||||
).changes,
|
||||
).toEqual([
|
||||
expect.objectContaining({
|
||||
logical_path: "record",
|
||||
classification: "changed",
|
||||
dimensions: ["metadata"],
|
||||
}),
|
||||
]);
|
||||
).toEqual([expectedPathChange("record", "changed", "metadata")]);
|
||||
// Equal declarations do not hide a change in content that a record names.
|
||||
expect(
|
||||
compareArtifacts(
|
||||
recordObservation(runtimeOption, { content: "a" }),
|
||||
recordObservation(runtimeOption, { content: "b" }),
|
||||
).changes,
|
||||
).toEqual([
|
||||
expect.objectContaining({
|
||||
logical_path: "record",
|
||||
classification: "changed",
|
||||
dimensions: ["content"],
|
||||
}),
|
||||
]);
|
||||
).toEqual([expectedPathChange("record", "changed", "content")]);
|
||||
});
|
||||
|
||||
it("compares a node-less record's occurrence fields but not its limitations", () => {
|
||||
@@ -1083,13 +1064,7 @@ it("compares a node-less record's occurrence fields but not its limitations", ()
|
||||
plain,
|
||||
recordObservation(namespace, { executable: true, limitations: [caveat] }),
|
||||
).changes,
|
||||
).toEqual([
|
||||
expect.objectContaining({
|
||||
logical_path: "record",
|
||||
classification: "changed",
|
||||
dimensions: ["executable"],
|
||||
}),
|
||||
]);
|
||||
).toEqual([expectedPathChange("record", "changed", "executable")]);
|
||||
// Limitations describe the observation, so a caveat alone is no change.
|
||||
expect(compareArtifacts(plain, recordObservation(namespace))).toMatchObject({
|
||||
status: "unchanged",
|
||||
@@ -1105,13 +1080,7 @@ it("compares a node-less record's recorded ASAR storage", () => {
|
||||
recordObservation(runtimeOption, { unpacked: false }),
|
||||
recordObservation(runtimeOption, { unpacked: true }),
|
||||
).changes,
|
||||
).toEqual([
|
||||
expect.objectContaining({
|
||||
logical_path: "record",
|
||||
classification: "changed",
|
||||
dimensions: ["metadata"],
|
||||
}),
|
||||
]);
|
||||
).toEqual([expectedPathChange("record", "changed", "metadata")]);
|
||||
expect(
|
||||
compareArtifacts(
|
||||
recordObservation(runtimeOption, { unpacked: true }),
|
||||
@@ -1219,13 +1188,7 @@ it("reports stored directory filename spelling changes on symlinks and unavailab
|
||||
),
|
||||
).toMatchObject({
|
||||
status: "changed",
|
||||
changes: [
|
||||
expect.objectContaining({
|
||||
logical_path: nfc,
|
||||
classification: "changed",
|
||||
dimensions: ["metadata"],
|
||||
}),
|
||||
],
|
||||
changes: [expectedPathChange(nfc, "changed", "metadata")],
|
||||
});
|
||||
|
||||
expect(
|
||||
|
||||
Reference in New Issue
Block a user