summaryrefslogtreecommitdiffhomepage
path: root/packages/opencode/test/tool/bash.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/opencode/test/tool/bash.test.ts')
-rw-r--r--packages/opencode/test/tool/bash.test.ts44
1 files changed, 44 insertions, 0 deletions
diff --git a/packages/opencode/test/tool/bash.test.ts b/packages/opencode/test/tool/bash.test.ts
new file mode 100644
index 000000000..ab92de457
--- /dev/null
+++ b/packages/opencode/test/tool/bash.test.ts
@@ -0,0 +1,44 @@
+import { describe, expect, test } from "bun:test"
+import { App } from "../../src/app/app"
+import path from "path"
+import { BashTool } from "../../src/tool/bash"
+import { Log } from "../../src/util/log"
+
+const ctx = {
+ sessionID: "test",
+ messageID: "",
+ abort: AbortSignal.any([]),
+ metadata: () => {},
+}
+
+const bash = await BashTool.init()
+const projectRoot = path.join(__dirname, "../..")
+Log.init({ print: false })
+
+describe("tool.bash", () => {
+ test("basic", async () => {
+ await App.provide({ cwd: projectRoot }, async () => {
+ await bash.execute(
+ {
+ command: "cd foo/bar && ls",
+ description: "List files in foo/bar",
+ },
+ ctx,
+ )
+ })
+ })
+
+ test("cd ../ should fail", async () => {
+ await App.provide({ cwd: projectRoot }, async () => {
+ expect(
+ bash.execute(
+ {
+ command: "cd ../",
+ description: "Try to cd to parent directory",
+ },
+ ctx,
+ ),
+ ).rejects.toThrow()
+ })
+ })
+})