(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestNewHandler_WithArguments(t *testing.T) { |
| 15 | t.Parallel() |
| 16 | |
| 17 | type Args struct { |
| 18 | Name string `json:"name"` |
| 19 | } |
| 20 | |
| 21 | handler := NewHandler(func(_ context.Context, args Args) (*ToolCallResult, error) { |
| 22 | return ResultSuccess("hello " + args.Name), nil |
| 23 | }) |
| 24 | |
| 25 | result, err := handler(t.Context(), ToolCall{ |
| 26 | ID: "call_1", |
| 27 | Type: "function", |
| 28 | Function: FunctionCall{ |
| 29 | Name: "greet", |
| 30 | Arguments: `{"name":"world"}`, |
| 31 | }, |
| 32 | }) |
| 33 | require.NoError(t, err) |
| 34 | assert.Equal(t, "hello world", result.Output) |
| 35 | } |
| 36 | |
| 37 | func TestNewHandler_EmptyArguments(t *testing.T) { |
| 38 | t.Parallel() |
nothing calls this directly
no test coverage detected