Skip to content

Commit f30ecae

Browse files
committed
fix: context passing
1 parent 9a3ebe7 commit f30ecae

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

tests/alloydbpg/alloydb_pg_integration_test.go

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

3636
args := []string{"--enable-api"}
3737

38-
pool, err := initAlloyDBPgConnectionPool(AlloyDBPostgresProject, AlloyDBPostgresRegion, AlloyDBPostgresCluster, AlloyDBPostgresInstance, "public", AlloyDBPostgresUser, AlloyDBPostgresPass, AlloyDBPostgresDatabase)
38+
pool, err := initAlloyDBPgConnectionPool(ctx, AlloyDBPostgresProject, AlloyDBPostgresRegion, AlloyDBPostgresCluster, AlloyDBPostgresInstance, "public", AlloyDBPostgresUser, AlloyDBPostgresPass, AlloyDBPostgresDatabase)
3939
if err != nil {
4040
t.Fatalf("unable to create AlloyDB connection pool: %s", err)
4141
}

tests/alloydbpg/alloydb_pg_mcp_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func getAlloyDBDialOpts(ipType string) ([]alloydbconn.DialOption, error) {
8383
}
8484
}
8585

86-
func initAlloyDBPgConnectionPool(project, region, cluster, instance, ipType, user, pass, dbname string) (*pgxpool.Pool, error) {
86+
func initAlloyDBPgConnectionPool(ctx context.Context, project, region, cluster, instance, ipType, user, pass, dbname string) (*pgxpool.Pool, error) {
8787
dsn := fmt.Sprintf("user=%s password=%s dbname=%s sslmode=disable", user, pass, dbname)
8888
config, err := pgxpool.ParseConfig(dsn)
8989
if err != nil {
@@ -94,7 +94,7 @@ func initAlloyDBPgConnectionPool(project, region, cluster, instance, ipType, use
9494
if err != nil {
9595
return nil, err
9696
}
97-
d, err := alloydbconn.NewDialer(context.Background(), alloydbconn.WithDefaultDialOptions(dialOpts...))
97+
d, err := alloydbconn.NewDialer(ctx, alloydbconn.WithDefaultDialOptions(dialOpts...))
9898
if err != nil {
9999
return nil, fmt.Errorf("unable to parse connection uri: %w", err)
100100
}
@@ -104,7 +104,7 @@ func initAlloyDBPgConnectionPool(project, region, cluster, instance, ipType, use
104104
return d.Dial(ctx, i)
105105
}
106106

107-
pool, err := pgxpool.NewWithConfig(context.Background(), config)
107+
pool, err := pgxpool.NewWithConfig(ctx, config)
108108
if err != nil {
109109
return nil, err
110110
}
@@ -148,7 +148,7 @@ func TestAlloyDBPgCallTool(t *testing.T) {
148148
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
149149
defer cancel()
150150

151-
pool, err := initAlloyDBPgConnectionPool(AlloyDBPostgresProject, AlloyDBPostgresRegion, AlloyDBPostgresCluster, AlloyDBPostgresInstance, "public", AlloyDBPostgresUser, AlloyDBPostgresPass, AlloyDBPostgresDatabase)
151+
pool, err := initAlloyDBPgConnectionPool(ctx, AlloyDBPostgresProject, AlloyDBPostgresRegion, AlloyDBPostgresCluster, AlloyDBPostgresInstance, "public", AlloyDBPostgresUser, AlloyDBPostgresPass, AlloyDBPostgresDatabase)
152152
if err != nil {
153153
t.Fatalf("unable to create AlloyDB connection pool: %s", err)
154154
}

0 commit comments

Comments
 (0)