Skip to content

Commit fa18a2d

Browse files
Jai Raj ChoudharyJai Raj Choudhary
authored andcommitted
refactired connection leak test go file
1 parent 1472ea7 commit fa18a2d

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

docs/fixes/connection_leak_test.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,10 @@ func TestConnectionPoolConfiguration(t *testing.T) {
106106
tests := []struct {
107107
name string
108108
maxConnections int
109-
expectError bool
110109
}{
111-
{"Normal pool size", 10, false},
112-
{"Large pool size", 100, false},
113-
{"Small pool size", 1, false},
110+
{"Normal pool size", 10},
111+
{"Large pool size", 100},
112+
{"Small pool size", 1},
114113
}
115114

116115
for _, tt := range tests {
@@ -123,14 +122,10 @@ func TestConnectionPoolConfiguration(t *testing.T) {
123122
assert.NoError(t, err, "Should not error within connection limit")
124123
}
125124

126-
// Try to exceed the limit
125+
// Try to exceed the limit - should always error
127126
err := mockStore.SimulateConnection("testdb")
128-
if tt.expectError {
129-
assert.Error(t, err, "Should error when exceeding connection limit")
130-
} else {
131-
// For our mock, we expect error when exceeding limit
132-
assert.Error(t, err, "Should error when exceeding connection limit")
133-
}
127+
assert.Error(t, err, "Should error when exceeding connection limit")
128+
assert.Equal(t, ErrTooManyConnections, err, "Should return specific error type")
134129
})
135130
}
136131
}

0 commit comments

Comments
 (0)