Skip to content

Commit a02ad86

Browse files
committed
fix(test): remove unnecessary app.Before() calls that overwrite test DB config
TestShell_BeforeNode and TestShell_RunNode_WithBeforeNode called app.Before(c) before BeforeNode(c). The Before hook unconditionally creates a fresh config with the default pgx driver, overwriting the test's txdb-wrapped config. This caused BeforeNode to open real DB connections that leaked state between tests, exhausting the connection pool. BeforeNode only needs Config and Logger — both already set by the test. The app.Before() call was unnecessary. Other tests in the same file (lines 258, 342, 420) correctly call BeforeNode directly without app.Before(). Fixes: CORE-2388
1 parent d62edd5 commit a02ad86

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

core/cmd/shell_local_test.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -543,15 +543,7 @@ func TestShell_BeforeNode(t *testing.T) {
543543

544544
c := cli.NewContext(nil, set, nil)
545545

546-
// Create full CLI app and run the Before hook first
547-
app := cmd.NewApp(&shell)
548-
err := app.Before(c)
549-
if err != nil && test.wantUnlocked {
550-
t.Fatalf("CLI Before hook failed: %v", err)
551-
}
552-
553-
// Run before hook to initialize components with authentication
554-
err = shell.BeforeNode(c)
546+
err := shell.BeforeNode(c)
555547

556548
if test.wantUnlocked {
557549
require.NoError(t, err)
@@ -641,12 +633,7 @@ func TestShell_RunNode_WithBeforeNode(t *testing.T) {
641633

642634
c := cli.NewContext(nil, set, nil)
643635

644-
// First initialize components (this includes authentication)
645-
cliApp := cmd.NewApp(&shell)
646-
err := cliApp.Before(c)
647-
require.NoError(t, err)
648-
649-
err = shell.BeforeNode(c)
636+
err := shell.BeforeNode(c)
650637

651638
if test.expectStart {
652639
require.NoError(t, err, "BeforeNode should succeed")

0 commit comments

Comments
 (0)