@@ -28,6 +28,7 @@ import (
2828 "testing"
2929
3030 "google.golang.org/api/iterator"
31+ "google.golang.org/genai"
3132)
3233
3334const defaultModel = "gemini-1.0-pro"
@@ -739,3 +740,40 @@ func printResponse(resp *GenerateContentResponse) {
739740 }
740741 fmt .Println ("---" )
741742}
743+
744+ func TestNewGenAIClient (t * testing.T ) {
745+ ctx := context .Background ()
746+ for _ , test := range []struct {
747+ name string
748+ cc * genai.ClientConfig
749+ }{
750+ {name : "nil config" , cc : nil },
751+ {name : "empty config" , cc : & genai.ClientConfig {}},
752+ } {
753+ t .Run (test .name , func (t * testing.T ) {
754+ client , err := NewGenAIClient (ctx , test .cc )
755+ if err != nil {
756+ t .Fatalf ("NewGenAIClient() failed unexpectedly, err: %v" , err )
757+ }
758+ if client == nil {
759+ t .Error ("client must not be nil" )
760+ }
761+ })
762+ }
763+ }
764+
765+ func TestNewGenAIClientErrors (t * testing.T ) {
766+ ctx := context .Background ()
767+ for _ , test := range []struct {
768+ name string
769+ cc * genai.ClientConfig
770+ }{
771+ {name : "gemini backend" , cc : & genai.ClientConfig {Backend : genai .BackendGeminiAPI }},
772+ } {
773+ t .Run (test .name , func (t * testing.T ) {
774+ if _ , err := NewGenAIClient (ctx , test .cc ); err == nil {
775+ t .Error ("wants error, but got nil" )
776+ }
777+ })
778+ }
779+ }
0 commit comments