test(opencode): simplify test registry layer wiring (#31761)

This commit is contained in:
James Long 2026-06-10 17:21:40 -04:00 committed by GitHub
commit eb70b6137b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 40 additions and 71 deletions

View file

@ -44,13 +44,20 @@ type CheckReplacementErrors<SourceError, ReplacementError> = [Exclude<Replacemen
? unknown
: { readonly "New replacement errors": Exclude<ReplacementError, SourceError> }
export function replace<A, E, E2>(
export function replaceWithNode<A, E, E2>(
source: Node<A, E>,
replacement: Node<NoInfer<A>, E2> & CheckReplacementErrors<E, NoInfer<E2>>,
): Replacement<A> {
return { source, replacement }
}
export function replace<A, E, E2>(
source: Node<A, E>,
replacement: Layer.Layer<NoInfer<A>, E2, never> & CheckReplacementErrors<E, NoInfer<E2>>,
): Replacement<A> {
return { source, replacement: make(replacement as Layer.Layer<A, E2>, []) }
}
export function buildLayer<A, E>(node: Node<A, E>, options?: { readonly replacements?: readonly Replacement[] }) {
const replacements = new Map(options?.replacements?.map((item) => [item.source, item.replacement]))
const cache = new Map<AnyNode, RuntimeLayer>()