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

Function TestParseExamples

pkg/config/examples_test.go:55–106  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

53}
54
55func TestParseExamples(t *testing.T) {
56 t.Parallel()
57
58 modelsStore, err := modelsdev.NewStore()
59 require.NoError(t, err)
60
61 for _, file := range collectExamples(t) {
62 t.Run(file, func(t *testing.T) {
63 t.Parallel()
64
65 cfg, err := Load(t.Context(), NewFileSource(file))
66
67 require.NoError(t, err)
68 require.Equal(t, latest.Version, cfg.Version, "Version should be %d in %s", latest.Version, file)
69 require.NotEmpty(t, cfg.Agents)
70 require.NotEmpty(t, cfg.Agents.First().Description, "Description should not be empty in %s", file)
71
72 for _, agent := range cfg.Agents {
73 if agent.Harness == nil {
74 require.NotEmpty(t, agent.Model)
75 }
76 require.NotEmpty(t, agent.Instruction, "Instruction should not be empty in %s", file)
77 }
78
79 for _, model := range cfg.Models {
80 // Skip first_available selectors - their provider/model is
81 // resolved at load time from the environment's credentials.
82 if model.IsFirstAvailable() {
83 continue
84 }
85 require.NotEmpty(t, model.Provider)
86 require.NotEmpty(t, model.Model)
87 // Skip providers that don't have entries in models.dev.
88 if modelsDevAbsentProviders[model.Provider] {
89 continue
90 }
91 // Skip models with routing rules - they use multiple providers
92 if len(model.Routing) > 0 {
93 continue
94 }
95 // Skip models that use custom providers (defined in cfg.Providers)
96 if _, isCustomProvider := cfg.Providers[model.Provider]; isCustomProvider {
97 continue
98 }
99
100 model, err := modelsStore.GetModel(t.Context(), modelsdev.NewID(model.Provider, model.Model))
101 require.NoError(t, err)
102 require.NotNil(t, model)
103 }
104 })
105 }
106}
107
108func TestParseExamplesAfterMarshalling(t *testing.T) {
109 t.Parallel()

Callers

nothing calls this directly

Calls 10

GetModelMethod · 0.95
NewStoreFunction · 0.92
NewIDFunction · 0.92
NewFileSourceFunction · 0.85
ContextMethod · 0.80
collectExamplesFunction · 0.70
LoadFunction · 0.70
RunMethod · 0.65
FirstMethod · 0.45
IsFirstAvailableMethod · 0.45

Tested by

no test coverage detected