From 1a834a0ff6ddbd6b00ee62f2228770f915cadd7d Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 21 Apr 2026 00:30:47 +0100 Subject: [PATCH] test: reuse runtime sidecar uniqueness helper --- src/plugins/runtime-sidecar-paths.ts | 5 ++++- test/helpers/plugins/public-artifacts.ts | 21 ++++----------------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/plugins/runtime-sidecar-paths.ts b/src/plugins/runtime-sidecar-paths.ts index 4838b73106d..065d617cd2c 100644 --- a/src/plugins/runtime-sidecar-paths.ts +++ b/src/plugins/runtime-sidecar-paths.ts @@ -1,6 +1,9 @@ import bundledRuntimeSidecarPaths from "../../scripts/lib/bundled-runtime-sidecar-paths.json" with { type: "json" }; -function assertUniqueValues(values: readonly T[], label: string): readonly T[] { +export function assertUniqueValues( + values: readonly T[], + label: string, +): readonly T[] { const seen = new Set(); const duplicates = new Set(); for (const value of values) { diff --git a/test/helpers/plugins/public-artifacts.ts b/test/helpers/plugins/public-artifacts.ts index 9d062b93c33..4c4193cfa32 100644 --- a/test/helpers/plugins/public-artifacts.ts +++ b/test/helpers/plugins/public-artifacts.ts @@ -1,20 +1,7 @@ -import { BUNDLED_RUNTIME_SIDECAR_PATHS } from "../../../src/plugins/runtime-sidecar-paths.js"; - -function assertUniqueValues(values: readonly T[], label: string): readonly T[] { - const seen = new Set(); - const duplicates = new Set(); - for (const value of values) { - if (seen.has(value)) { - duplicates.add(value); - continue; - } - seen.add(value); - } - if (duplicates.size > 0) { - throw new Error(`Duplicate ${label}: ${Array.from(duplicates).join(", ")}`); - } - return values; -} +import { + assertUniqueValues, + BUNDLED_RUNTIME_SIDECAR_PATHS, +} from "../../../src/plugins/runtime-sidecar-paths.js"; export function getPublicArtifactBasename(relativePath: string): string { return relativePath.split("/").at(-1) ?? relativePath;