test(desktop): share package owner fixture replies (#16586)

This commit is contained in:
Vincent Koc authored and GitHub committed 2026-12-04 12:39:44 +08:00
1 parent d2323a454f
commit 275ad75606
1 file changed
+23 -83
@@ -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<string, string>,
) => ({
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,
);