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

Function TestNewHandler_NoTelemetryOnValidInput

pkg/tools/tools_test.go:157–179  ·  view source on GitHub ↗

TestNewHandler_NoTelemetryOnValidInput pins the hot-path contract: a well-formed tool call must NOT emit tool_input_repaired. Without this, a regression in aijson's strict-first ordering would silently flood logs.

(t *testing.T)

Source from the content-addressed store, hash-verified

155// well-formed tool call must NOT emit tool_input_repaired. Without this,
156// a regression in aijson's strict-first ordering would silently flood logs.
157func TestNewHandler_NoTelemetryOnValidInput(t *testing.T) {
158 var buf bytes.Buffer
159 prev := slog.Default()
160 slog.SetDefault(slog.New(slog.NewTextHandler(&buf, &slog.HandlerOptions{Level: slog.LevelInfo})))
161 t.Cleanup(func() { slog.SetDefault(prev) })
162
163 type args struct {
164 Paths []string `json:"paths"`
165 }
166 handler := NewHandler(func(_ context.Context, _ args) (*ToolCallResult, error) {
167 return ResultSuccess("ok"), nil
168 })
169
170 _, err := handler(t.Context(), ToolCall{
171 Type: "function",
172 Function: FunctionCall{
173 Name: "read_multiple_files",
174 Arguments: `{"paths":["a.txt","b.txt"]}`,
175 },
176 })
177 require.NoError(t, err)
178 assert.NotContains(t, buf.String(), "tool_input_repaired")
179}
180
181func TestToolCallResultWithoutPayload(t *testing.T) {
182 t.Parallel()

Callers

nothing calls this directly

Calls 6

StringMethod · 0.95
ResultSuccessFunction · 0.85
ContextMethod · 0.80
NewHandlerFunction · 0.70
CleanupMethod · 0.65
NewMethod · 0.45

Tested by

no test coverage detected