@@ -291,7 +291,7 @@ func TestNewClient(t *testing.T) {
291
291
}
292
292
})
293
293
294
- t .Run ("API Key from environment " , func (t * testing.T ) {
294
+ t .Run ("API Key from GOOGLE_API_KEY only " , func (t * testing.T ) {
295
295
apiKey := "test-api-key-env"
296
296
client , err := NewClient (ctx , & ClientConfig {Backend : BackendGeminiAPI ,
297
297
envVarProvider : func () map [string ]string {
@@ -307,6 +307,59 @@ func TestNewClient(t *testing.T) {
307
307
t .Errorf ("Expected API key %q, got %q" , apiKey , client .clientConfig .APIKey )
308
308
}
309
309
})
310
+ t .Run ("API Key from GEMINI_API_KEY only" , func (t * testing.T ) {
311
+ apiKey := "test-api-key-env"
312
+ client , err := NewClient (ctx , & ClientConfig {Backend : BackendGeminiAPI ,
313
+ envVarProvider : func () map [string ]string {
314
+ return map [string ]string {
315
+ "GEMINI_API_KEY" : apiKey ,
316
+ }
317
+ },
318
+ })
319
+ if err != nil {
320
+ t .Fatalf ("Expected no error, got %v" , err )
321
+ }
322
+ if client .clientConfig .APIKey != apiKey {
323
+ t .Errorf ("Expected API key %q, got %q" , apiKey , client .clientConfig .APIKey )
324
+ }
325
+ })
326
+
327
+ t .Run ("API Key from GEMINI_API_KEY and GOOGLE_API_KEY as empty string" , func (t * testing.T ) {
328
+ apiKey := "test-api-key-env"
329
+ client , err := NewClient (ctx , & ClientConfig {Backend : BackendGeminiAPI ,
330
+ envVarProvider : func () map [string ]string {
331
+ return map [string ]string {
332
+ "GOOGLE_API_KEY" : "" ,
333
+ "GEMINI_API_KEY" : apiKey ,
334
+ }
335
+ },
336
+ })
337
+ if err != nil {
338
+ t .Fatalf ("Expected no error, got %v" , err )
339
+ }
340
+ if client .clientConfig .APIKey != apiKey {
341
+ t .Errorf ("Expected API key %q, got %q" , apiKey , client .clientConfig .APIKey )
342
+ }
343
+ })
344
+
345
+ t .Run ("API Key both GEMINI_API_KEY and GOOGLE_API_KEY" , func (t * testing.T ) {
346
+ geminiAPIKey := "gemini-api-key-env"
347
+ googleAPIKey := "google-api-key-env"
348
+ client , err := NewClient (ctx , & ClientConfig {Backend : BackendGeminiAPI ,
349
+ envVarProvider : func () map [string ]string {
350
+ return map [string ]string {
351
+ "GOOGLE_API_KEY" : googleAPIKey ,
352
+ "GEMINI_API_KEY" : geminiAPIKey ,
353
+ }
354
+ },
355
+ })
356
+ if err != nil {
357
+ t .Fatalf ("Expected no error, got %v" , err )
358
+ }
359
+ if client .clientConfig .APIKey != googleAPIKey {
360
+ t .Errorf ("Expected APIggcg key %q, got %q" , googleAPIKey , client .clientConfig .APIKey )
361
+ }
362
+ })
310
363
311
364
t .Run ("Base URL from HTTPOptions" , func (t * testing.T ) {
312
365
baseURL := "https://test-base-url.com/"
0 commit comments