MCPcopy Create free account
hub / github.com/docker/docker-agent / TestNewRuntime_ModelStorePrecedence

Function TestNewRuntime_ModelStorePrecedence

pkg/runtime/runtime_test.go:951–989  ·  view source on GitHub ↗

TestNewRuntime_ModelStorePrecedence pins the resolution order for the runtime's models.dev store: an explicit WithModelStore wins; otherwise a store carried on the ModelSwitcherConfig is adopted (this is how the team loader shares the catalog it already warmed); otherwise the runtime builds its own

(t *testing.T)

Source from the content-addressed store, hash-verified

949// its own lazy store. Sharing the warmed store is what keeps the first /model
950// open from re-paying the multi-MB catalog parse.
951func TestNewRuntime_ModelStorePrecedence(t *testing.T) {
952 t.Parallel()
953
954 newTeam := func() *team.Team {
955 root := agent.New("root", "test", agent.WithModel(&mockProvider{id: "test/m"}))
956 return team.New(team.WithAgents(root))
957 }
958
959 t.Run("explicit WithModelStore wins over ModelSwitcherConfig", func(t *testing.T) {
960 t.Parallel()
961 explicit := &mockCatalogStore{}
962 cfgStore := &mockCatalogStore{}
963 rt, err := NewLocalRuntime(t.Context(), newTeam(),
964 WithModelStore(explicit),
965 WithModelSwitcherConfig(&ModelSwitcherConfig{ModelsStore: cfgStore}),
966 )
967 require.NoError(t, err)
968 assert.Same(t, explicit, rt.modelsStore)
969 })
970
971 t.Run("ModelSwitcherConfig store is adopted when no explicit store", func(t *testing.T) {
972 t.Parallel()
973 cfgStore := &mockCatalogStore{}
974 rt, err := NewLocalRuntime(t.Context(), newTeam(),
975 WithModelSwitcherConfig(&ModelSwitcherConfig{ModelsStore: cfgStore}),
976 )
977 require.NoError(t, err)
978 assert.Same(t, cfgStore, rt.modelsStore)
979 })
980
981 t.Run("falls back to lazy store when neither is set", func(t *testing.T) {
982 t.Parallel()
983 rt, err := NewLocalRuntime(t.Context(), newTeam(),
984 WithModelSwitcherConfig(&ModelSwitcherConfig{}),
985 )
986 require.NoError(t, err)
987 assert.IsType(t, &lazyModelStore{}, rt.modelsStore)
988 })
989}
990
991func TestProcessToolCalls_UnknownTool_ReturnsErrorResponse(t *testing.T) {
992 t.Parallel()

Callers

nothing calls this directly

Calls 8

NewFunction · 0.92
NewFunction · 0.92
WithAgentsFunction · 0.92
NewLocalRuntimeFunction · 0.85
WithModelStoreFunction · 0.85
WithModelSwitcherConfigFunction · 0.85
ContextMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected