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

Function TestModelOverride

pkg/agent/agent_test.go:345–371  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

343func (m *mockProvider) BaseConfig() base.Config { return base.Config{} }
344
345func TestModelOverride(t *testing.T) {
346 t.Parallel()
347
348 defaultModel := &mockProvider{id: modelsdev.NewID("openai", "gpt-4o")}
349 overrideModel := &mockProvider{id: modelsdev.NewID("anthropic", "claude-sonnet-4-0")}
350
351 a := New("root", "test", WithModel(defaultModel))
352
353 // Initially should return the default model
354 assert.Equal(t, "openai/gpt-4o", a.Model(t.Context()).ID().String())
355 assert.False(t, a.HasModelOverride())
356
357 // Set an override
358 a.SetModelOverride(overrideModel)
359 assert.True(t, a.HasModelOverride())
360 assert.Equal(t, "anthropic/claude-sonnet-4-0", a.Model(t.Context()).ID().String())
361
362 // ConfiguredModels still reflects the originally configured models
363 configuredModels := a.ConfiguredModels()
364 require.Len(t, configuredModels, 1)
365 assert.Equal(t, "openai/gpt-4o", configuredModels[0].ID().String())
366
367 // Clear the override
368 a.SetModelOverride(nil)
369 assert.False(t, a.HasModelOverride())
370 assert.Equal(t, "openai/gpt-4o", a.Model(t.Context()).ID().String())
371}
372
373func TestSetModelOverride_ReturnsSnapshotOfStoredValue(t *testing.T) {
374 // SetModelOverride must return a snapshot of the value it just stored,

Callers

nothing calls this directly

Calls 11

NewIDFunction · 0.92
ModelMethod · 0.80
ContextMethod · 0.80
HasModelOverrideMethod · 0.80
SetModelOverrideMethod · 0.80
ConfiguredModelsMethod · 0.80
NewFunction · 0.70
WithModelFunction · 0.70
IDMethod · 0.65
LenMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected