diff --git a/tests/boundary/filesystem/desktopNeededOrigin.test.ts b/tests/boundary/filesystem/desktopNeededOrigin.test.ts index 49b1d49d799..f8c6eb9fcd1 100644 --- a/tests/boundary/filesystem/desktopNeededOrigin.test.ts +++ b/tests/boundary/filesystem/desktopNeededOrigin.test.ts @@ -14,6 +14,20 @@ import { inspectLibraryPackages } from "../../../src/desktop/LibraryPackageInven import { elfImage } from "../../../src/domain/desktop/elfImage.fixture.js"; import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js"; +const packageOwnerReply = ( + args: readonly string[], + owners: ReadonlyMap, +) => ({ + stdout: args + .slice(1) + .flatMap((path) => { + const owner = owners.get(path); + return owner === undefined ? [] : [`${owner}: ${path}`]; + }) + .join("\n"), + exitCode: 0, +}); + it.skipIf(process.platform === "win32")( "retains every required symlink package while walking its physical target once", async () => { @@ -58,16 +72,7 @@ it.skipIf(process.platform === "win32")( async (command, args) => command === "ldconfig" ? { stdout: "", exitCode: 0 } - : { - stdout: args - .slice(1) - .flatMap((path) => { - const owner = owners.get(path); - return owner === undefined ? [] : [`${owner}: ${path}`]; - }) - .join("\n"), - exitCode: 0, - }, + : packageOwnerReply(args, owners), undefined, ); expect(report).toEqual({ @@ -164,15 +169,7 @@ it : "", exitCode: 0, }; - return { - stdout: args - .slice(1) - .flatMap((path) => - owners.has(path) ? [`${owners.get(path)}: ${path}`] : [], - ) - .join("\n"), - exitCode: 0, - }; + return packageOwnerReply(args, owners); }, undefined, ); @@ -217,15 +214,7 @@ it.skipIf(process.platform === "win32")( async (command, args) => command === "ldconfig" ? { stdout: "", exitCode: 0 } - : { - stdout: args - .slice(1) - .flatMap((path) => - owners.has(path) ? [`${owners.get(path)}: ${path}`] : [], - ) - .join("\n"), - exitCode: 0, - }, + : packageOwnerReply(args, owners), undefined, ); expect(result).toEqual({ @@ -283,15 +272,7 @@ it.skipIf(process.platform === "win32")( async (command, args) => { if (command === "ldconfig") return { stdout: "", exitCode: 0 }; queried.push(...args.slice(1)); - return { - stdout: args - .slice(1) - .flatMap((path) => - owners.has(path) ? [`${owners.get(path)}: ${path}`] : [], - ) - .join("\n"), - exitCode: 0, - }; + return packageOwnerReply(args, owners); }, undefined, ); @@ -463,15 +444,7 @@ it.skipIf(process.platform === "win32").each([ async (command, args) => { if (command === "ldconfig") return { stdout: "", exitCode: 0 }; queried.push(...args.slice(1)); - return { - stdout: args - .slice(1) - .flatMap((path) => - owners.has(path) ? [`${owners.get(path)}: ${path}`] : [], - ) - .join("\n"), - exitCode: 0, - }; + return packageOwnerReply(args, owners); }, undefined, ); @@ -516,15 +489,7 @@ it.skipIf(process.platform === "win32")( async (command, args) => { if (command === "ldconfig") return { stdout: "", exitCode: 0 }; queried.push(...args.slice(1)); - return { - stdout: args - .slice(1) - .flatMap((path) => - owners.has(path) ? [`${owners.get(path)}: ${path}`] : [], - ) - .join("\n"), - exitCode: 0, - }; + return packageOwnerReply(args, owners); }, undefined, ); @@ -580,15 +545,7 @@ it.skipIf(process.platform === "win32").each([ async (command, args) => command === "ldconfig" ? { stdout: "", exitCode: 0 } - : { - stdout: args - .slice(1) - .flatMap((path) => - owners.has(path) ? [`${owners.get(path)}: ${path}`] : [], - ) - .join("\n"), - exitCode: 0, - }, + : packageOwnerReply(args, owners), undefined, ); expect(report).toEqual({ @@ -635,15 +592,7 @@ it.skipIf(process.platform === "win32").each([false, true])( async (command, args) => command === "ldconfig" ? { stdout: "", exitCode: 0 } - : { - stdout: args - .slice(1) - .flatMap((path) => - owners.has(path) ? [`${owners.get(path)}: ${path}`] : [], - ) - .join("\n"), - exitCode: 0, - }, + : packageOwnerReply(args, owners), undefined, ); expect(report).toEqual({ @@ -880,16 +829,7 @@ it.skipIf(process.platform === "win32").each([ async (command, args) => { if (command === "ldconfig") return { stdout: "", exitCode: 0 }; queried.push(...args.slice(1)); - return { - stdout: args - .slice(1) - .flatMap((path) => { - const owner = owners.get(path); - return owner === undefined ? [] : [`${owner}: ${path}`]; - }) - .join("\n"), - exitCode: 0, - }; + return packageOwnerReply(args, owners); }, undefined, );