test(server): expand workspace routing fixed-id coverage (#26458)

This commit is contained in:
Kit Langton
2026-05-09 00:00:18 -04:00
committed by GitHub
parent 96bde05f6e
commit cbdb2d9825
2 changed files with 83 additions and 8 deletions
+20
View File
@@ -0,0 +1,20 @@
import type { WorkspaceID } from "@/control-plane/schema"
import { Flag } from "@opencode-ai/core/flag/flag"
import { Effect, Scope } from "effect"
/**
* Scoped override for `Flag.OPENCODE_WORKSPACE_ID`. Saves the previous value
* on entry and restores it via finalizer when the surrounding scope closes —
* preserves the original try/finally semantics regardless of test outcome.
*/
export function withFixedWorkspaceID(id: WorkspaceID): Effect.Effect<void, never, Scope.Scope> {
return Effect.gen(function* () {
const previous = Flag.OPENCODE_WORKSPACE_ID
Flag.OPENCODE_WORKSPACE_ID = id
yield* Effect.addFinalizer(() =>
Effect.sync(() => {
Flag.OPENCODE_WORKSPACE_ID = previous
}),
)
})
}