Files
opencode/packages/opencode/test/server/config-providers-httpapi.test.ts
T
Kit Langton 370690c1f8 add experimental config providers HttpApi slice
Add a parallel experimental config providers HttpApi endpoint, keep the schema local to the slice for now, and normalize the provider payload through JSON serialization so the draft route returns a stable JSON shape.
2026-04-14 20:43:38 -04:00

29 lines
1.0 KiB
TypeScript

import { describe, expect, test } from "bun:test"
import { Server } from "../../src/server/server"
import { Log } from "../../src/util/log"
import { tmpdir } from "../fixture/fixture"
Log.init({ print: false })
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")
})
})