Skip to content

Commit aa1537c

Browse files
committed
fix: context passing
1 parent a10c605 commit aa1537c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

tests/cloudsqlpg/cloud_sql_pg_integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func TestCloudSQLPgSimpleToolEndpoints(t *testing.T) {
3333

3434
args := []string{"--enable-api"}
3535

36-
pool, err := initCloudSQLPgConnectionPool(CloudSQLPostgresProject, CloudSQLPostgresRegion, CloudSQLPostgresInstance, "public", CloudSQLPostgresUser, CloudSQLPostgresPass, CloudSQLPostgresDatabase)
36+
pool, err := initCloudSQLPgConnectionPool(ctx, CloudSQLPostgresProject, CloudSQLPostgresRegion, CloudSQLPostgresInstance, "public", CloudSQLPostgresUser, CloudSQLPostgresPass, CloudSQLPostgresDatabase)
3737
if err != nil {
3838
t.Fatalf("unable to create Cloud SQL connection pool: %s", err)
3939
}

tests/cloudsqlpg/cloud_sql_pg_mcp_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)