test(iso9660): share descriptor sector fixture setup (#16845)

This commit is contained in:
Vincent Koc authored and GitHub committed 2026-12-05 05:34:12 +08:00
1 parent 5cd3af6237
commit 1678ca46a5
1 file changed
+8 -10
+8 -10
View File
@@ -63,6 +63,12 @@ const descriptors = (image: Buffer) =>
image.length,
);
const descriptorSectors = (bytes: Buffer, primary: number) => (index: number) =>
bytes.subarray(
primary + index * ISO9660_SECTOR_BYTES,
primary + (index + 1) * ISO9660_SECTOR_BYTES,
);
it("accepts a volume partition descriptor and rejects reserved types", () => {
const { bytes, layout } = buildIso9660Image({ joliet: true });
const offset = layout.primaryDescriptor + ISO9660_SECTOR_BYTES;
@@ -207,11 +213,7 @@ it("keeps the primary tree when a Joliet descriptor is not eligible", () => {
it("derives the primary-tree fallback only after a later Joliet descriptor is weighed", () => {
const { bytes, layout } = buildIso9660Image({ joliet: true });
const sector = (index: number) =>
bytes.subarray(
layout.primaryDescriptor + index * ISO9660_SECTOR_BYTES,
layout.primaryDescriptor + (index + 1) * ISO9660_SECTOR_BYTES,
);
const sector = descriptorSectors(bytes, layout.primaryDescriptor);
const skipped = Buffer.from(sector(1));
skipped[6] = 2;
const parsed = parseIso9660VolumeDescriptors(
@@ -239,11 +241,7 @@ it("reports image-wide tree coverage as unknown whenever another tree is not wal
});
const { bytes, layout } = buildIso9660Image({ joliet: true });
const supplementary = layout.primaryDescriptor + ISO9660_SECTOR_BYTES;
const sector = (index: number) =>
bytes.subarray(
layout.primaryDescriptor + index * ISO9660_SECTOR_BYTES,
layout.primaryDescriptor + (index + 1) * ISO9660_SECTOR_BYTES,
);
const sector = descriptorSectors(bytes, layout.primaryDescriptor);
// A second Joliet descriptor names a tree that is not walked.
const repeated = parseIso9660VolumeDescriptors(
Buffer.concat([sector(0), sector(1), sector(1), sector(2)]),