Skip to content

Commit fe30608

Browse files
authored
run goleaks in places where it is missing (#156)
1 parent 2a04345 commit fe30608

File tree

6 files changed

+40
-4
lines changed

6 files changed

+40
-4
lines changed

cmd/dbos/cli_integration_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
_ "github.com/jackc/pgx/v5/stdlib"
2424
"github.com/stretchr/testify/assert"
2525
"github.com/stretchr/testify/require"
26+
"go.uber.org/goleak"
2627
)
2728

2829
//go:embed cli_test_app.go.test
@@ -51,6 +52,11 @@ func getDatabaseURL() string {
5152

5253
// TestCLIWorkflow provides comprehensive integration testing of the DBOS CLI
5354
func TestCLIWorkflow(t *testing.T) {
55+
defer goleak.VerifyNone(t,
56+
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).backgroundHealthCheck"),
57+
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck"),
58+
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck.func1"),
59+
)
5460
// Build the CLI once at the beginning
5561
cliPath := buildCLI(t)
5662
t.Logf("Built CLI at: %s", cliPath)

dbos/admin_server_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,15 @@ import (
1414

1515
"github.com/stretchr/testify/assert"
1616
"github.com/stretchr/testify/require"
17+
"go.uber.org/goleak"
1718
)
1819

1920
func TestAdminServer(t *testing.T) {
21+
defer goleak.VerifyNone(t,
22+
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).backgroundHealthCheck"),
23+
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck"),
24+
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck.func1"),
25+
)
2026
databaseURL := getDatabaseURL()
2127

2228
t.Run("Admin server is not started by default", func(t *testing.T) {

dbos/dbos_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@ import (
1111
"github.com/jackc/pgx/v5/pgxpool"
1212
"github.com/stretchr/testify/assert"
1313
"github.com/stretchr/testify/require"
14+
"go.uber.org/goleak"
1415
)
1516

1617
func TestConfig(t *testing.T) {
18+
defer goleak.VerifyNone(t,
19+
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).backgroundHealthCheck"),
20+
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck"),
21+
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck.func1"),
22+
)
1723
databaseURL := getDatabaseURL()
1824

1925
t.Run("CreatesDBOSContext", func(t *testing.T) {
@@ -275,6 +281,11 @@ func TestConfig(t *testing.T) {
275281
}
276282

277283
func TestCustomSystemDBSchema(t *testing.T) {
284+
defer goleak.VerifyNone(t,
285+
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).backgroundHealthCheck"),
286+
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck"),
287+
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck.func1"),
288+
)
278289
t.Setenv("DBOS__APPVERSION", "v1.0.0")
279290
t.Setenv("DBOS__APPID", "test-custom-schema")
280291
t.Setenv("DBOS__VMID", "test-executor-id")
@@ -464,6 +475,11 @@ func TestCustomSystemDBSchema(t *testing.T) {
464475
}
465476

466477
func TestCustomPool(t *testing.T) {
478+
defer goleak.VerifyNone(t,
479+
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).backgroundHealthCheck"),
480+
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck"),
481+
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck.func1"),
482+
)
467483
// Test workflows for custom pool testing
468484
type customPoolWorkflowInput struct {
469485
PartnerWorkflowID string

dbos/logger_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@ import (
99

1010
"github.com/stretchr/testify/assert"
1111
"github.com/stretchr/testify/require"
12+
"go.uber.org/goleak"
1213
)
1314

1415
func TestLogger(t *testing.T) {
16+
defer goleak.VerifyNone(t,
17+
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).backgroundHealthCheck"),
18+
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck"),
19+
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck.func1"),
20+
)
1521
databaseURL := getDatabaseURL()
1622

1723
t.Run("Default logger", func(t *testing.T) {

dbos/workflows_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ func TestWorkflowsRegistration(t *testing.T) {
284284

285285
t.Run("DoubleRegistrationWithoutName", func(t *testing.T) {
286286
// Create a fresh DBOS context for this test
287-
freshCtx := setupDBOS(t, false, false) // Don't check for leaks and don't reset DB
287+
freshCtx := setupDBOS(t, false, true) // Don't reset DB but do check for leaks
288288

289289
// First registration should work
290290
RegisterWorkflow(freshCtx, simpleWorkflow)
@@ -302,7 +302,7 @@ func TestWorkflowsRegistration(t *testing.T) {
302302

303303
t.Run("DoubleRegistrationWithCustomName", func(t *testing.T) {
304304
// Create a fresh DBOS context for this test
305-
freshCtx := setupDBOS(t, false, false) // Don't check for leaks and don't reset DB
305+
freshCtx := setupDBOS(t, false, true) // Don't reset DB but do check for leaks
306306

307307
// First registration with custom name should work
308308
RegisterWorkflow(freshCtx, simpleWorkflow, WithWorkflowName("custom-workflow"))
@@ -320,7 +320,7 @@ func TestWorkflowsRegistration(t *testing.T) {
320320

321321
t.Run("DifferentWorkflowsSameCustomName", func(t *testing.T) {
322322
// Create a fresh DBOS context for this test
323-
freshCtx := setupDBOS(t, false, false) // Don't check for leaks and don't reset DB
323+
freshCtx := setupDBOS(t, false, true) // Don't reset DB but do check for leaks
324324

325325
// First registration with custom name should work
326326
RegisterWorkflow(freshCtx, simpleWorkflow, WithWorkflowName("same-name"))
@@ -338,7 +338,7 @@ func TestWorkflowsRegistration(t *testing.T) {
338338

339339
t.Run("RegisterAfterLaunchPanics", func(t *testing.T) {
340340
// Create a fresh DBOS context for this test
341-
freshCtx := setupDBOS(t, false, false) // Don't check for leaks and don't reset DB
341+
freshCtx := setupDBOS(t, false, true) // Don't reset DB but do check for leaks
342342

343343
// Launch DBOS context
344344
err := freshCtx.Launch()

integration/mocks_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/dbos-inc/dbos-transact-golang/dbos"
1212
"github.com/stretchr/testify/mock"
13+
"go.uber.org/goleak"
1314
)
1415

1516
func step(ctx context.Context) (int, error) {
@@ -142,6 +143,7 @@ func aRealProgramFunction(dbosCtx dbos.DBOSContext) error {
142143
}
143144

144145
func TestMocks(t *testing.T) {
146+
defer goleak.VerifyNone(t)
145147
mockCtx := mocks.NewMockDBOSContext(t)
146148

147149
// Context lifecycle

0 commit comments

Comments
 (0)