@@ -69,7 +69,7 @@ func getCloudSQLPgVars(t *testing.T) map[string]any {
6969 }
7070}
7171
72- func initCloudSQLPgConnectionPool (project , region , instance , ip_type , user , pass , dbname string ) (* pgxpool.Pool , error ) {
72+ func initCloudSQLPgConnectionPool (ctx context. Context , project , region , instance , ip_type , user , pass , dbname string ) (* pgxpool.Pool , error ) {
7373 dsn := fmt .Sprintf ("user=%s password=%s dbname=%s sslmode=disable" , user , pass , dbname )
7474 config , err := pgxpool .ParseConfig (dsn )
7575 if err != nil {
@@ -81,7 +81,7 @@ func initCloudSQLPgConnectionPool(project, region, instance, ip_type, user, pass
8181 if err != nil {
8282 return nil , err
8383 }
84- d , err := cloudsqlconn .NewDialer (context . Background () , cloudsqlconn .WithDefaultDialOptions (dialOpts ... ))
84+ d , err := cloudsqlconn .NewDialer (ctx , cloudsqlconn .WithDefaultDialOptions (dialOpts ... ))
8585 if err != nil {
8686 return nil , fmt .Errorf ("unable to parse connection uri: %w" , err )
8787 }
@@ -93,7 +93,7 @@ func initCloudSQLPgConnectionPool(project, region, instance, ip_type, user, pass
9393 }
9494
9595 // Interact with the driver directly as you normally would
96- pool , err := pgxpool .NewWithConfig (context . Background () , config )
96+ pool , err := pgxpool .NewWithConfig (ctx , config )
9797 if err != nil {
9898 return nil , err
9999 }
@@ -136,7 +136,7 @@ func TestCloudSQLPgCallTool(t *testing.T) {
136136 ctx , cancel := context .WithTimeout (context .Background (), 2 * time .Minute )
137137 defer cancel ()
138138
139- pool , err := initCloudSQLPgConnectionPool (CloudSQLPostgresProject , CloudSQLPostgresRegion , CloudSQLPostgresInstance , "public" , CloudSQLPostgresUser , CloudSQLPostgresPass , CloudSQLPostgresDatabase )
139+ pool , err := initCloudSQLPgConnectionPool (ctx , CloudSQLPostgresProject , CloudSQLPostgresRegion , CloudSQLPostgresInstance , "public" , CloudSQLPostgresUser , CloudSQLPostgresPass , CloudSQLPostgresDatabase )
140140 if err != nil {
141141 t .Fatalf ("unable to create Cloud SQL connection pool: %s" , err )
142142 }
0 commit comments