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

Function TestGetEffectiveRetries

pkg/runtime/fallback_test.go:382–399  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

380}
381
382func TestGetEffectiveRetries(t *testing.T) {
383 t.Parallel()
384
385 mockModel := &mockProvider{id: "test/model", stream: newStreamBuilder().AddContent("ok").AddStopWithUsage(1, 1).Build()}
386 mockFallback := &mockProvider{id: "test/fallback", stream: newStreamBuilder().AddContent("ok").AddStopWithUsage(1, 1).Build()}
387
388 agentNoFallback := agent.New("no-fallback", "test", agent.WithModel(mockModel))
389 assert.Equal(t, modelerrors.DefaultRetries, getEffectiveRetries(agentNoFallback), "should use default retries even without fallback models")
390
391 agentWithFallback := agent.New("with-fallback", "test", agent.WithModel(mockModel), agent.WithFallbackModel(mockFallback))
392 assert.Equal(t, modelerrors.DefaultRetries, getEffectiveRetries(agentWithFallback), "should use default retries when fallback models configured")
393
394 agentExplicitRetries := agent.New("explicit-retries", "test", agent.WithModel(mockModel), agent.WithFallbackModel(mockFallback), agent.WithFallbackRetries(5))
395 assert.Equal(t, 5, getEffectiveRetries(agentExplicitRetries), "should use configured retries")
396
397 agentNoRetries := agent.New("no-retries", "test", agent.WithModel(mockModel), agent.WithFallbackModel(mockFallback), agent.WithFallbackRetries(-1))
398 assert.Equal(t, 0, getEffectiveRetries(agentNoRetries), "retries=-1 should return 0 (no retries)")
399}
400
401func TestFallback429WithFallbacksSkipsToNextModel(t *testing.T) {
402 t.Parallel()

Callers

nothing calls this directly

Calls 9

NewFunction · 0.92
WithModelFunction · 0.92
WithFallbackModelFunction · 0.92
WithFallbackRetriesFunction · 0.92
newStreamBuilderFunction · 0.85
getEffectiveRetriesFunction · 0.85
AddStopWithUsageMethod · 0.80
BuildMethod · 0.45
AddContentMethod · 0.45

Tested by

no test coverage detected