MCPcopy Index your code
hub / github.com/docker/docker-agent / TestNewHandler_WithArguments

Function TestNewHandler_WithArguments

pkg/tools/tools_test.go:14–35  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func 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
37func TestNewHandler_EmptyArguments(t *testing.T) {
38 t.Parallel()

Callers

nothing calls this directly

Calls 3

ResultSuccessFunction · 0.85
ContextMethod · 0.80
NewHandlerFunction · 0.70

Tested by

no test coverage detected