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

Function TestFetchModelsFromURL_Success

cmd/root/models_test.go:166–183  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

164}
165
166func TestFetchModelsFromURL_Success(t *testing.T) {
167 t.Parallel()
168
169 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
170 assert.Equal(t, "/v1/models", r.URL.Path)
171 w.Header().Set("Content-Type", "application/json")
172 _, err := w.Write([]byte(`{"object":"list","data":[
173 {"id":"model-a","object":"model"},
174 {"id":"model-b","object":"model"},
175 {"id":"model-c","object":"model"}
176 ]}`))
177 assert.NoError(t, err)
178 }))
179 t.Cleanup(server.Close)
180
181 models := fetchModelsFromURL(t.Context(), server.URL+"/v1/models", server.Client())
182 assert.Equal(t, []string{"model-a", "model-b", "model-c"}, models)
183}
184
185func TestFetchModelsFromURL_Non200(t *testing.T) {
186 t.Parallel()

Callers

nothing calls this directly

Calls 5

fetchModelsFromURLFunction · 0.85
ContextMethod · 0.80
CleanupMethod · 0.65
SetMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected