Repository navigation
Expand file tree
/
Copy pathhttpapi-reference.test.ts
More file actions
53 lines (49 loc) · 1.49 KB
/
Copy pathhttpapi-reference.test.ts
File metadata and controls
53 lines (49 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { afterEach, describe, expect, test } from "bun:test"
import path from "path"
import { Server } from "../../src/server/server"
import { Global } from "@opencode-ai/core/global"
import { resetDatabase } from "../fixture/db"
import { disposeAllInstances, tmpdir } from "../fixture/fixture"
afterEach(async () => {
await disposeAllInstances()
await resetDatabase()
})
describe("reference HttpApi", () => {
test("lists presentation-safe references resolved in the server workspace", async () => {
await using tmp = await tmpdir({
config: {
formatter: false,
lsp: false,
reference: {
docs: "./docs",
effect: { repository: "Effect-TS/effect", branch: "main" },
bad: "not-a-repo",
},
},
})
const response = await Server.Default().app.request("/reference", {
headers: { "x-opencode-directory": tmp.path },
})
expect(response.status).toBe(200)
expect(await response.json()).toEqual([
{
name: "docs",
kind: "local",
path: path.join(tmp.path, "docs"),
},
{
name: "effect",
kind: "git",
repository: "Effect-TS/effect",
path: path.join(Global.Path.repos, "github.com", "Effect-TS", "effect"),
branch: "main",
},
{
name: "bad",
kind: "invalid",
repository: "not-a-repo",
message: "Repository must be a git URL, host/path reference, or GitHub owner/repo shorthand",
},
])
})
})