test(opencode): retry Windows CLI cleanup
This commit is contained in:
parent
81851ca6b9
commit
9b01f15f1d
2 changed files with 15 additions and 6 deletions
|
|
@ -20,7 +20,7 @@
|
||||||
import { test, type TestOptions } from "bun:test"
|
import { test, type TestOptions } from "bun:test"
|
||||||
import { FSUtil } from "@opencode-ai/core/fs-util"
|
import { FSUtil } from "@opencode-ai/core/fs-util"
|
||||||
import { AppProcess } from "@opencode-ai/core/process"
|
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 { FetchHttpClient, HttpClient } from "effect/unstable/http"
|
||||||
import { ChildProcess } from "effect/unstable/process"
|
import { ChildProcess } from "effect/unstable/process"
|
||||||
import path from "node:path"
|
import path from "node:path"
|
||||||
|
|
@ -192,9 +192,13 @@ export function withCliFixture<A, E>(
|
||||||
const fs = yield* FSUtil.Service
|
const fs = yield* FSUtil.Service
|
||||||
const appProc = yield* AppProcess.Service
|
const appProc = yield* AppProcess.Service
|
||||||
|
|
||||||
// FileSystem.makeTempDirectoryScoped handles both creation and scope-tied
|
const home = yield* fs.makeTempDirectory({ prefix: "oc-cli-" })
|
||||||
// cleanup — replaces the old mkdir + addFinalizer pair.
|
yield* Effect.addFinalizer(() =>
|
||||||
const home = yield* fs.makeTempDirectoryScoped({ prefix: "oc-cli-" })
|
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 configJson = JSON.stringify(testProviderConfig(llm.url))
|
||||||
const env = isolatedEnv(home, configJson)
|
const env = isolatedEnv(home, configJson)
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import { TestLLMServer } from "../lib/llm-server"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { resetDatabase } from "../fixture/db"
|
import { resetDatabase } from "../fixture/db"
|
||||||
import { disposeAllInstances, TestInstance, tmpdirScoped } from "../fixture/fixture"
|
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 { testProviderConfig } from "../lib/test-provider"
|
||||||
import { ProviderV2 } from "@opencode-ai/core/provider"
|
import { ProviderV2 } from "@opencode-ai/core/provider"
|
||||||
import { ModelV2 } from "@opencode-ai/core/model"
|
import { ModelV2 } from "@opencode-ai/core/model"
|
||||||
|
|
@ -389,7 +389,12 @@ describe("HttpApi SDK", () => {
|
||||||
workspaceID,
|
workspaceID,
|
||||||
onRequest: (value) => (request = value),
|
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)
|
const url = new URL(request!.url)
|
||||||
|
|
||||||
expect(found.response.status).toBe(200)
|
expect(found.response.status).toBe(200)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue