Skip to content

Commit b77b543

Browse files
authored
test(coderd/database/pubsub): ensure db closure on unhappy paths (#16327)
1 parent c069563 commit b77b543

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

coderd/database/pubsub/pubsub_linux_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,9 @@ func TestMeasureLatency(t *testing.T) {
305305
require.NoError(t, err)
306306
db, err := sql.Open("postgres", connectionURL)
307307
require.NoError(t, err)
308+
t.Cleanup(func() {
309+
_ = db.Close()
310+
})
308311
ps, err := pubsub.New(ctx, logger, db, connectionURL)
309312
require.NoError(t, err)
310313

coderd/database/pubsub/pubsub_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ func TestPGPubsubDriver(t *testing.T) {
137137
// use a separate subber and pubber so we can keep track of listener connections
138138
db, err := sql.Open("postgres", connectionURL)
139139
require.NoError(t, err)
140+
defer db.Close()
140141
pubber, err := pubsub.New(ctx, logger, db, connectionURL)
141142
require.NoError(t, err)
142143
defer pubber.Close()
@@ -147,6 +148,7 @@ func TestPGPubsubDriver(t *testing.T) {
147148
tconn, err := subDriver.Connector(connectionURL)
148149
require.NoError(t, err)
149150
tcdb := sql.OpenDB(tconn)
151+
defer tcdb.Close()
150152
subber, err := pubsub.New(ctx, logger, tcdb, connectionURL)
151153
require.NoError(t, err)
152154
defer subber.Close()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy