forked from anomalyco/opencode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbash.test.ts
More file actions
55 lines (51 loc) · 1.47 KB
/
bash.test.ts
File metadata and controls
55 lines (51 loc) · 1.47 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
54
55
import { describe, expect, test } from "bun:test"
import path from "path"
import { BashTool } from "../../src/tool/bash"
import { Instance } from "../../src/project/instance"
import { Permission } from "../../src/permission"
const ctx = {
sessionID: "test",
messageID: "",
toolCallID: "",
agent: "build",
abort: AbortSignal.any([]),
metadata: () => {},
}
const projectRoot = path.join(__dirname, "../..")
describe("tool.bash", () => {
test("basic", async () => {
await Instance.provide({
directory: projectRoot,
fn: async () => {
const bash = await BashTool.init()
const result = await bash.execute(
{
command: "echo 'test'",
description: "Echo test message",
},
ctx,
)
expect(result.metadata.exit).toBe(0)
expect(result.metadata.output).toContain("test")
},
})
})
// TODO: better test
// test("cd ../ should ask for permission for external directory", async () => {
// await Instance.provide({
// directory: projectRoot,
// fn: async () => {
// bash.execute(
// {
// command: "cd ../",
// description: "Try to cd to parent directory",
// },
// ctx,
// )
// // Give time for permission to be asked
// await new Promise((resolve) => setTimeout(resolve, 1000))
// expect(Permission.pending()[ctx.sessionID]).toBeDefined()
// },
// })
// })
})