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

Function TestAPITool_CustomOutputSchema

pkg/tools/builtin/api/api_test.go:174–208  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

172}
173
174func TestAPITool_CustomOutputSchema(t *testing.T) {
175 t.Parallel()
176
177 customSchema := map[string]any{
178 "type": "object",
179 "properties": map[string]any{
180 "first_name": map[string]any{"type": "string"},
181 "last_name": map[string]any{"type": "string"},
182 "age": map[string]any{"type": "number"},
183 },
184 "required": []string{"first_name", "last_name"},
185 }
186
187 tool := New(latest.APIToolConfig{
188 Name: "user-info",
189 Method: http.MethodGet,
190 Endpoint: "https://example.com/api/users/${id}",
191 Required: []string{"id"},
192 Args: map[string]any{"id": map[string]any{"type": "number"}},
193 OutputSchema: customSchema,
194 }, testExpander())
195
196 toolsList, err := tool.Tools(t.Context())
197 require.NoError(t, err)
198 require.Len(t, toolsList, 1)
199
200 schema, ok := toolsList[0].OutputSchema.(map[string]any)
201 require.True(t, ok)
202 assert.Equal(t, "object", schema["type"])
203
204 props, ok := schema["properties"].(map[string]any)
205 require.True(t, ok)
206 assert.Contains(t, props, "first_name")
207 assert.Contains(t, props, "age")
208}
209
210func TestAPITool_RejectsLocalAddresses(t *testing.T) {
211 t.Parallel()

Callers

nothing calls this directly

Calls 5

testExpanderFunction · 0.85
ContextMethod · 0.80
NewFunction · 0.70
ToolsMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected