testTool is a helper function to test a tool and mark it as tested. Note that we test the _generic_ version of the tool and not the typed one. This is to mimic how we expect external callers to use the tool.
(t *testing.T, tool toolsdk.Tool[Arg, Ret], tb toolsdk.Deps, args Arg)
| 2370 | // Note that we test the _generic_ version of the tool and not the typed one. |
| 2371 | // This is to mimic how we expect external callers to use the tool. |
| 2372 | func testTool[Arg, Ret any](t *testing.T, tool toolsdk.Tool[Arg, Ret], tb toolsdk.Deps, args Arg) (Ret, error) { |
| 2373 | t.Helper() |
| 2374 | defer func() { testedTools.Store(tool.Name, true) }() |
| 2375 | toolArgs, err := json.Marshal(args) |
| 2376 | require.NoError(t, err, "failed to marshal args") |
| 2377 | result, err := tool.Generic().Handler(t.Context(), tb, toolArgs) |
| 2378 | var ret Ret |
| 2379 | require.NoError(t, json.Unmarshal(result, &ret), "failed to unmarshal result %q", string(result)) |
| 2380 | return ret, err |
| 2381 | } |
| 2382 | |
| 2383 | func TestWithRecovery(t *testing.T) { |
| 2384 | t.Parallel() |
no test coverage detected