cloudaxe-opencode/packages/opencode/test/server/config-providers-httpapi.test.ts
Kit Langton 0c430ada0b test(config): dispose instances after httpapi test
Align the config providers HttpApi server test with the shared instance cleanup pattern used by the other experimental slices.
2026-04-14 20:43:38 -04:00

33 lines
1.2 KiB
TypeScript

import { afterEach, describe, expect, test } from "bun:test"
import { Instance } from "../../src/project/instance"
import { Server } from "../../src/server/server"
import { Log } from "../../src/util/log"
import { tmpdir } from "../fixture/fixture"
Log.init({ print: false })
afterEach(async () => {
await Instance.disposeAll()
})
describe("experimental config providers httpapi", () => {
test("lists config providers and serves docs", async () => {
await using tmp = await tmpdir({ git: true })
const app = Server.Default().app
const headers = {
"content-type": "application/json",
"x-opencode-directory": tmp.path,
}
const res = await app.request("/experimental/httpapi/config/providers", { headers })
expect(res.status).toBe(200)
const body = await res.json()
expect(Array.isArray(body.providers)).toBe(true)
expect(typeof body.default).toBe("object")
const doc = await app.request("/experimental/httpapi/config/doc", { headers })
expect(doc.status).toBe(200)
const spec = await doc.json()
expect(spec.paths["/experimental/httpapi/config/providers"]?.get?.operationId).toBe("config.providers")
})
})