mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-10-09 03:18:04 +00:00
test(tools): type scoped operation results
This commit is contained in:
parent
da19beafb2
commit
d09b7026f9
1 changed files with 10 additions and 4 deletions
|
|
@ -30,9 +30,15 @@ import * as openAi from "./openai/tools"
|
|||
|
||||
const API_KEY = "sm_test_key"
|
||||
|
||||
type ToolWithExecute = { execute: (args: Record<string, unknown>) => unknown }
|
||||
type ToolExecutionResult = { success: boolean; error?: string }
|
||||
type ToolWithExecute = {
|
||||
execute: (args: Record<string, unknown>) => Promise<ToolExecutionResult>
|
||||
}
|
||||
|
||||
function executeTool(tool: unknown, args: Record<string, unknown>) {
|
||||
function executeTool(
|
||||
tool: unknown,
|
||||
args: Record<string, unknown>,
|
||||
): Promise<ToolExecutionResult> {
|
||||
return (tool as ToolWithExecute).execute(args)
|
||||
}
|
||||
|
||||
|
|
@ -57,7 +63,7 @@ describe("configured container scope", () => {
|
|||
const fetchMock = vi.fn()
|
||||
vi.stubGlobal("fetch", fetchMock)
|
||||
|
||||
const results = (await Promise.all([
|
||||
const results: ToolExecutionResult[] = await Promise.all([
|
||||
executeTool(aiSdk.getProfileTool(API_KEY, config), {
|
||||
containerTag: "tenant-b",
|
||||
}),
|
||||
|
|
@ -87,7 +93,7 @@ describe("configured container scope", () => {
|
|||
containerTag: "tenant-b",
|
||||
memoryId: "mem_1",
|
||||
}),
|
||||
])) as Array<{ success: boolean; error?: string }>
|
||||
])
|
||||
|
||||
expect(results).toHaveLength(6)
|
||||
for (const result of results) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue