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

Function TestMaxIterationsAutoApproveSafetyCap

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

Source from the content-addressed store, hash-verified

160}
161
162func TestMaxIterationsAutoApproveSafetyCap(t *testing.T) {
163 t.Parallel()
164
165 // Emit maxAutoExtensions+1 events to trigger the safety cap
166 events := make([]runtime.Event, maxAutoExtensions+1)
167 for i := range events {
168 events[i] = maxIterEvent(60 + i*10)
169 }
170
171 rt := &mockRuntime{events: events}
172
173 var buf bytes.Buffer
174 out := NewPrinter(&buf)
175 sess := session.New()
176 cfg := Config{AutoApprove: true}
177
178 err := Run(t.Context(), out, cfg, rt, sess, []string{"hello"})
179 assert.NilError(t, err)
180
181 resumes := rt.getResumes()
182 assert.Equal(t, len(resumes), maxAutoExtensions+1)
183
184 // First maxAutoExtensions should be approved
185 for i := range maxAutoExtensions {
186 assert.Equal(t, resumes[i].Type, runtime.ResumeTypeApprove,
187 "extension %d should be approved", i+1)
188 }
189 // Last one should be rejected (safety cap)
190 assert.Equal(t, resumes[maxAutoExtensions].Type, runtime.ResumeTypeReject,
191 "extension beyond cap should be rejected")
192}
193
194func TestMaxIterationsAutoApproveJSONMode(t *testing.T) {
195 t.Parallel()

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