MCPcopy Create free account
hub / github.com/InferCore/InferCore / TestAdapterConformance_Gemini

Function TestAdapterConformance_Gemini

internal/adapters/conformance_test.go:172–209  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

170}
171
172func TestAdapterConformance_Gemini(t *testing.T) {
173 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
174 if r.Header.Get("x-goog-api-key") == "" {
175 w.WriteHeader(http.StatusUnauthorized)
176 return
177 }
178 switch {
179 case r.Method == http.MethodGet && r.URL.Path == "/v1beta/models":
180 w.WriteHeader(http.StatusOK)
181 case r.Method == http.MethodPost && strings.HasSuffix(r.URL.Path, ":generateContent"):
182 w.Header().Set("Content-Type", "application/json")
183 _ = json.NewEncoder(w).Encode(map[string]any{
184 "candidates": []map[string]any{
185 {
186 "content": map[string]any{
187 "parts": []map[string]any{{"text": "hello from gemini"}},
188 },
189 },
190 },
191 })
192 default:
193 http.NotFound(w, r)
194 }
195 }))
196 defer srv.Close()
197
198 adapter := gemini.New(config.BackendConfig{
199 Name: "gem-b",
200 Type: "gemini",
201 Endpoint: srv.URL,
202 TimeoutMS: 200,
203 APIKey: "test-key",
204 DefaultModel: "gemini-2.0-flash",
205 Capabilities: []string{"chat"},
206 Cost: config.CostConfig{Unit: 2},
207 })
208 assertAdapterConformance(t, adapter)
209}
210
211func assertAdapterConformance(t *testing.T, adapter interfaces.BackendAdapter) {
212 t.Helper()

Callers

nothing calls this directly

Calls 4

NewFunction · 0.92
assertAdapterConformanceFunction · 0.85
WriteHeaderMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected