test: reuse runtime sidecar uniqueness helper

This commit is contained in:
Peter Steinberger
2026-04-21 00:30:47 +01:00
parent 883f66eef3
commit 1a834a0ff6
2 changed files with 8 additions and 18 deletions

View File

@@ -1,6 +1,9 @@
import bundledRuntimeSidecarPaths from "../../scripts/lib/bundled-runtime-sidecar-paths.json" with { type: "json" };
function assertUniqueValues<T extends string>(values: readonly T[], label: string): readonly T[] {
export function assertUniqueValues<T extends string>(
values: readonly T[],
label: string,
): readonly T[] {
const seen = new Set<string>();
const duplicates = new Set<string>();
for (const value of values) {

View File

@@ -1,20 +1,7 @@
import { BUNDLED_RUNTIME_SIDECAR_PATHS } from "../../../src/plugins/runtime-sidecar-paths.js";
function assertUniqueValues<T extends string>(values: readonly T[], label: string): readonly T[] {
const seen = new Set<string>();
const duplicates = new Set<string>();
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;