diff --git a/packages/opencode/test/server/httpapi-exercise/backend.ts b/packages/opencode/test/server/httpapi-exercise/backend.ts index fac5f699c3..b306401ccd 100644 --- a/packages/opencode/test/server/httpapi-exercise/backend.ts +++ b/packages/opencode/test/server/httpapi-exercise/backend.ts @@ -2,7 +2,7 @@ import { ConfigProvider, Effect, Layer } from "effect" import { HttpRouter } from "effect/unstable/http" import { parse } from "./assertions" import { runtime, type Runtime } from "./runtime" -import type { ActiveScenario, Backend, BackendApp, CallResult, CaptureMode, SeededContext } from "./types" +import type { ActiveScenario, BackendApp, CallResult, CaptureMode, SeededContext } from "./types" type CallOptions = { auth?: { @@ -11,27 +11,18 @@ type CallOptions = { } } -export function call( - backend: Backend, - scenario: ActiveScenario, - ctx: SeededContext, - options: CallOptions = {}, -) { +export function call(scenario: ActiveScenario, ctx: SeededContext, options: CallOptions = {}) { return Effect.promise(async () => - capture(await app(await runtime(), backend, options).request(toRequest(scenario, ctx)), scenario.capture), + capture(await app(await runtime(), options).request(toRequest(scenario, ctx)), scenario.capture), ) } -export function callAuthProbe( - backend: Backend, - scenario: ActiveScenario, - credentials: "missing" | "valid" = "missing", -) { +export function callAuthProbe(scenario: ActiveScenario, credentials: "missing" | "valid" = "missing") { return Effect.promise(async () => { const controller = new AbortController() return Promise.race([ Promise.resolve( - app(await runtime(), backend, { auth: { password: "secret" } }).request( + app(await runtime(), { auth: { password: "secret" } }).request( toAuthProbeRequest(scenario, credentials, controller.signal), ), ).then((response) => capture(response, scenario.capture)), @@ -51,10 +42,10 @@ export function callAuthProbe( const appCache: Partial> = {} -function app(modules: Runtime, backend: Backend, options: CallOptions) { +function app(modules: Runtime, options: CallOptions) { const username = options.auth?.username const password = options.auth?.password - const cacheKey = `${backend}:${username ?? ""}:${password ?? ""}` + const cacheKey = `${username ?? ""}:${password ?? ""}` if (appCache[cacheKey]) return appCache[cacheKey] const handler = HttpRouter.toWebHandler( diff --git a/packages/opencode/test/server/httpapi-exercise/runner.ts b/packages/opencode/test/server/httpapi-exercise/runner.ts index 2b3f720c84..bc246dbeda 100644 --- a/packages/opencode/test/server/httpapi-exercise/runner.ts +++ b/packages/opencode/test/server/httpapi-exercise/runner.ts @@ -30,28 +30,28 @@ function runActive(options: Options, scenario: ActiveScenario) { return withContext(options, scenario, "shared", (ctx) => Effect.gen(function* () { - yield* trace(options, scenario, "effect request start") - const effect = yield* call("effect", scenario, ctx) - yield* trace(options, scenario, `effect response ${effect.status}`) - yield* trace(options, scenario, "effect expect start") - yield* scenario.expect(ctx, ctx.state, effect) - yield* trace(options, scenario, "effect expect done") + yield* trace(options, scenario, "request start") + const result = yield* call(scenario, ctx) + yield* trace(options, scenario, `response ${result.status}`) + yield* trace(options, scenario, "expect start") + yield* scenario.expect(ctx, ctx.state, result) + yield* trace(options, scenario, "expect done") }), ) } function runAuth(scenario: ActiveScenario) { return Effect.gen(function* () { - const effect = yield* callAuthProbe("effect", scenario, "missing") + const result = yield* callAuthProbe(scenario, "missing") if (scenario.auth === "protected") { - if (effect.status !== 401) throw new Error(`effect auth expected 401, got ${effect.status}`) - const effectAuthed = yield* callAuthProbe("effect", scenario, "valid") - if (effectAuthed.status === 401) throw new Error("effect auth rejected valid credentials") + if (result.status !== 401) throw new Error(`auth expected 401, got ${result.status}`) + const authed = yield* callAuthProbe(scenario, "valid") + if (authed.status === 401) throw new Error("auth rejected valid credentials") return } - if (effect.status === 401) throw new Error("effect auth expected public access, got 401") - if (effect.timedOut) throw new Error("effect auth expected public access, probe timed out") + if (result.status === 401) throw new Error("auth expected public access, got 401") + if (result.timedOut) throw new Error("auth expected public access, probe timed out") }) } diff --git a/packages/opencode/test/server/httpapi-exercise/types.ts b/packages/opencode/test/server/httpapi-exercise/types.ts index a0466d7b70..e1fe93ba7e 100644 --- a/packages/opencode/test/server/httpapi-exercise/types.ts +++ b/packages/opencode/test/server/httpapi-exercise/types.ts @@ -11,7 +11,6 @@ export const Methods = ["GET", "POST", "PUT", "DELETE", "PATCH"] as const export type Method = (typeof Methods)[number] export type OpenApiMethod = (typeof OpenApiMethods)[number] export type Mode = "effect" | "coverage" | "auth" -export type Backend = "effect" export type Comparison = "none" | "status" | "json" export type CaptureMode = "full" | "stream" export type AuthPolicy = "protected" | "public" | "public-bypass" | "ticket-bypass"