mirror of
https://github.com/affaan-m/ECC.git
synced 2026-09-11 04:07:54 +02:00
test(opencode): assert init does not call shell and root plugin tools
This commit is contained in:
@@ -62,12 +62,17 @@ function main() {
|
||||
assert.deepStrictEqual(Object.keys(mod).sort(), ["default"])
|
||||
assert.strictEqual(typeof mod.default, "function")
|
||||
|
||||
let shellCalls = 0
|
||||
const plugin = await mod.default({
|
||||
client: { app: { log: () => {} } },
|
||||
$: async () => { throw new Error("$ must not be called during plugin init") },
|
||||
$: async () => {
|
||||
shellCalls += 1
|
||||
throw new Error("$ must not be called during plugin init")
|
||||
},
|
||||
directory: process.cwd(),
|
||||
worktree: process.cwd(),
|
||||
})
|
||||
assert.strictEqual(shellCalls, 0, "$ must not be called during plugin init")
|
||||
assert.ok(plugin && typeof plugin === "object", "default export must return a plugin record")
|
||||
const expectedHooks = [
|
||||
"file.edited",
|
||||
@@ -85,6 +90,18 @@ function main() {
|
||||
for (const hook of expectedHooks) {
|
||||
assert.strictEqual(typeof plugin[hook], "function", "missing hook: " + hook)
|
||||
}
|
||||
assert.deepStrictEqual(
|
||||
Object.keys(plugin.tool).sort(),
|
||||
["changed-files", "dependency-analyzer"],
|
||||
"plugin.tool must expose exactly the custom tools"
|
||||
)
|
||||
for (const toolName of ["changed-files", "dependency-analyzer"]) {
|
||||
const toolDefinition = plugin.tool[toolName]
|
||||
assert.ok(toolDefinition && typeof toolDefinition === "object", "missing tool: " + toolName)
|
||||
assert.strictEqual(typeof toolDefinition.description, "string", toolName + " must declare a description")
|
||||
assert.ok(toolDefinition.args && typeof toolDefinition.args === "object", toolName + " must declare args")
|
||||
assert.strictEqual(typeof toolDefinition.execute, "function", toolName + " must declare an execute function")
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
|
||||
Reference in New Issue
Block a user