MCPcopy
hub / github.com/docker/docker-agent / TestCodeModeTool_CallHello

Function TestCodeModeTool_CallHello

pkg/tools/codemode/codemode_test.go:126–157  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

124}
125
126func TestCodeModeTool_CallHello(t *testing.T) {
127 t.Parallel()
128 tool := Wrap(&testToolSet{
129 tools: []tools.Tool{
130 {
131 Name: "hello_world",
132 Handler: tools.NewHandler(func(ctx context.Context, args map[string]any) (*tools.ToolCallResult, error) {
133 return tools.ResultSuccess("Hello, World!"), nil
134 }),
135 },
136 },
137 })
138
139 allTools, err := tool.Tools(t.Context())
140 require.NoError(t, err)
141 require.Len(t, allTools, 1)
142
143 result, err := allTools[0].Handler(t.Context(), tools.ToolCall{
144 Function: tools.FunctionCall{
145 Arguments: `{"script":"return hello_world();"}`,
146 },
147 })
148 require.NoError(t, err)
149
150 var scriptResult ScriptResult
151 err = json.Unmarshal([]byte(result.Output), &scriptResult)
152 require.NoError(t, err)
153
154 require.Equal(t, "Hello, World!", scriptResult.Value)
155 require.Empty(t, scriptResult.StdErr)
156 require.Empty(t, scriptResult.StdOut)
157}
158
159func TestCodeModeTool_CallEcho(t *testing.T) {
160 t.Parallel()

Callers

nothing calls this directly

Calls 6

NewHandlerFunction · 0.92
ResultSuccessFunction · 0.92
WrapFunction · 0.85
ContextMethod · 0.80
ToolsMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected