MCPcopy Index your code
hub / github.com/anomalyco/opencode / mockTuiRuntime

Function mockTuiRuntime

packages/opencode/test/fixture/tui-runtime.ts:32–56  ·  view source on GitHub ↗
(dir: string, plugin: PluginSpec[], opts?: { plugin_enabled?: Record<string, boolean> })

Source from the content-addressed store, hash-verified

30}
31
32export function mockTuiRuntime(dir: string, plugin: PluginSpec[], opts?: { plugin_enabled?: Record<string, boolean> }) {
33 process.env.OPENCODE_PLUGIN_META_FILE = path.join(dir, "plugin-meta.json")
34 const plugin_origins = plugin.map((spec) => ({
35 spec,
36 scope: "local" as const,
37 source: path.join(dir, "tui.json"),
38 }))
39 const wait = spyOn(TuiConfig, "waitForDependencies").mockResolvedValue()
40 const cwd = spyOn(process, "cwd").mockImplementation(() => dir)
41
42 const config = createTuiResolvedConfig({
43 plugin,
44 plugin_origins,
45 ...(opts?.plugin_enabled && { plugin_enabled: opts.plugin_enabled }),
46 })
47
48 return {
49 config,
50 restore: () => {
51 cwd.mockRestore()
52 wait.mockRestore()
53 delete process.env.OPENCODE_PLUGIN_META_FILE
54 },
55 }
56}

Callers 2

Calls 1

createTuiResolvedConfigFunction · 0.70

Tested by

no test coverage detected