test(opencode): retry Windows CLI cleanup
This commit is contained in:
parent
81851ca6b9
commit
9b01f15f1d
@ -20,7 +20,7 @@
|
||||
import { test, type TestOptions } from "bun:test"
|
||||
import { FSUtil } from "@opencode-ai/core/fs-util"
|
||||
import { AppProcess } from "@opencode-ai/core/process"
|
||||
import { Deferred, Duration, Effect, Layer, Queue, Scope, Stream } from "effect"
|
||||
import { Deferred, Duration, Effect, Layer, Queue, Schedule, Scope, Stream } from "effect"
|
||||
import { FetchHttpClient, HttpClient } from "effect/unstable/http"
|
||||
import { ChildProcess } from "effect/unstable/process"
|
||||
import path from "node:path"
|
||||
@ -192,9 +192,13 @@ export function withCliFixture<A, E>(
|
||||
const fs = yield* FSUtil.Service
|
||||
const appProc = yield* AppProcess.Service
|
||||
|
||||
// FileSystem.makeTempDirectoryScoped handles both creation and scope-tied
|
||||
// cleanup — replaces the old mkdir + addFinalizer pair.
|
||||
const home = yield* fs.makeTempDirectoryScoped({ prefix: "oc-cli-" })
|
||||
const home = yield* fs.makeTempDirectory({ prefix: "oc-cli-" })
|
||||
yield* Effect.addFinalizer(() =>
|
||||
fs.remove(home, { recursive: true }).pipe(
|
||||
Effect.retry(Schedule.spaced("50 millis").pipe(Schedule.both(Schedule.recurs(20)))),
|
||||
Effect.ignore,
|
||||
),
|
||||
)
|
||||
|
||||
const configJson = JSON.stringify(testProviderConfig(llm.url))
|
||||
const env = isolatedEnv(home, configJson)
|
||||
|
||||
@ -22,7 +22,7 @@ import { TestLLMServer } from "../lib/llm-server"
|
||||
import path from "path"
|
||||
import { resetDatabase } from "../fixture/db"
|
||||
import { disposeAllInstances, TestInstance, tmpdirScoped } from "../fixture/fixture"
|
||||
import { awaitWithTimeout, testEffect } from "../lib/effect"
|
||||
import { awaitWithTimeout, pollWithTimeout, testEffect } from "../lib/effect"
|
||||
import { testProviderConfig } from "../lib/test-provider"
|
||||
import { ProviderV2 } from "@opencode-ai/core/provider"
|
||||
import { ModelV2 } from "@opencode-ai/core/model"
|
||||
@ -389,7 +389,12 @@ describe("HttpApi SDK", () => {
|
||||
workspaceID,
|
||||
onRequest: (value) => (request = value),
|
||||
})
|
||||
const found = yield* call(() => sdk.v2.fs.find({ query: "hello", type: "file" }))
|
||||
const found = yield* pollWithTimeout(
|
||||
call(() => sdk.v2.fs.find({ query: "hello", type: "file" })).pipe(
|
||||
Effect.map((result) => (result.data?.data.length ? result : undefined)),
|
||||
),
|
||||
"SDK file search index was not ready",
|
||||
)
|
||||
const url = new URL(request!.url)
|
||||
|
||||
expect(found.response.status).toBe(200)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user