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

Function TestMaxIterationsSafetyCapJSONMode

pkg/cli/runner_test.go:293–318  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

291}
292
293func TestMaxIterationsSafetyCapJSONMode(t *testing.T) {
294 t.Parallel()
295
296 events := make([]runtime.Event, maxAutoExtensions+1)
297 for i := range events {
298 events[i] = maxIterEvent(60 + i*10)
299 }
300
301 rt := &mockRuntime{events: events}
302
303 var buf bytes.Buffer
304 out := NewPrinter(&buf)
305 sess := session.New()
306 cfg := Config{AutoApprove: true, OutputJSON: true}
307
308 err := Run(t.Context(), out, cfg, rt, sess, []string{"hello"})
309 assert.NilError(t, err)
310
311 resumes := rt.getResumes()
312 assert.Equal(t, len(resumes), maxAutoExtensions+1)
313
314 for i := range maxAutoExtensions {
315 assert.Equal(t, resumes[i].Type, runtime.ResumeTypeApprove)
316 }
317 assert.Equal(t, resumes[maxAutoExtensions].Type, runtime.ResumeTypeReject)
318}
319
320// TestPrepareUserMessage_AgentSwitching tests that PrepareUserMessage correctly
321// handles agent-switching commands and returns empty messages on switch failures.

Callers

nothing calls this directly

Calls 6

getResumesMethod · 0.95
NewFunction · 0.92
maxIterEventFunction · 0.85
NewPrinterFunction · 0.85
ContextMethod · 0.80
RunFunction · 0.70

Tested by

no test coverage detected