mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-19 08:44:22 +01:00
chore: enhance bash command tests with config mock and timeout adjustments (#1486)
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
This commit is contained in:
@@ -19,19 +19,21 @@ Log.init({ print: false })
|
|||||||
describe("tool.bash", () => {
|
describe("tool.bash", () => {
|
||||||
test("basic", async () => {
|
test("basic", async () => {
|
||||||
await App.provide({ cwd: projectRoot }, async () => {
|
await App.provide({ cwd: projectRoot }, async () => {
|
||||||
await bash.execute(
|
const result = await bash.execute(
|
||||||
{
|
{
|
||||||
command: "cd foo/bar && ls",
|
command: "echo 'test'",
|
||||||
description: "List files in foo/bar",
|
description: "Echo test message",
|
||||||
},
|
},
|
||||||
ctx,
|
ctx,
|
||||||
)
|
)
|
||||||
|
expect(result.metadata.exit).toBe(0)
|
||||||
|
expect(result.metadata.stdout).toContain("test")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test("cd ../ should fail", async () => {
|
test("cd ../ should fail outside of project root", async () => {
|
||||||
await App.provide({ cwd: projectRoot }, async () => {
|
await App.provide({ cwd: projectRoot }, async () => {
|
||||||
expect(
|
await expect(
|
||||||
bash.execute(
|
bash.execute(
|
||||||
{
|
{
|
||||||
command: "cd ../",
|
command: "cd ../",
|
||||||
@@ -39,7 +41,7 @@ describe("tool.bash", () => {
|
|||||||
},
|
},
|
||||||
ctx,
|
ctx,
|
||||||
),
|
),
|
||||||
).rejects.toThrow()
|
).rejects.toThrow("This command references paths outside of")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user