@@ -857,6 +857,7 @@ func TestPool(t *testing.T) {
857
857
}, WithDialer (func (Dialer ) Dialer { return d }))
858
858
err := p .ready ()
859
859
noerr (t , err )
860
+ defer p .close (context .Background ())
860
861
861
862
c , err := p .checkOut (context .Background ())
862
863
noerr (t , err )
@@ -871,8 +872,6 @@ func TestPool(t *testing.T) {
871
872
assert .Equalf (t , 0 , d .lenclosed (), "should have closed 0 connections" )
872
873
assert .Equalf (t , 1 , p .availableConnectionCount (), "should have 1 idle connections in pool" )
873
874
assert .Equalf (t , 1 , p .totalConnectionCount (), "should have 1 total connection in pool" )
874
-
875
- p .close (context .Background ())
876
875
})
877
876
t .Run ("sets minPoolSize connection idle deadline" , func (t * testing.T ) {
878
877
t .Parallel ()
@@ -892,14 +891,15 @@ func TestPool(t *testing.T) {
892
891
}, WithDialer (func (Dialer ) Dialer { return d }))
893
892
err := p .ready ()
894
893
noerr (t , err )
894
+ defer p .close (context .Background ())
895
895
896
896
// Wait for maintain() to open 3 connections.
897
897
assertConnectionsOpened (t , d , 3 )
898
898
899
899
// Sleep for 100ms, which will exceed the 10ms connection idle timeout, then try to check
900
900
// out a connection. Expect that all minPoolSize connections checked into the pool by
901
- // maintain() have passed their idle deadline, so checkOut() close all 3 connections and
902
- // try to create a new connection.
901
+ // maintain() have passed their idle deadline, so checkOut() closes all 3 connections
902
+ // and tries to create a new connection.
903
903
time .Sleep (100 * time .Millisecond )
904
904
_ , err = p .checkOut (context .Background ())
905
905
noerr (t , err )
@@ -908,8 +908,6 @@ func TestPool(t *testing.T) {
908
908
assert .Equalf (t , 4 , d .lenopened (), "should have opened 4 connections" )
909
909
assert .Equalf (t , 0 , p .availableConnectionCount (), "should have 0 idle connections in pool" )
910
910
assert .Equalf (t , 1 , p .totalConnectionCount (), "should have 1 total connection in pool" )
911
-
912
- p .close (context .Background ())
913
911
})
914
912
})
915
913
t .Run ("maintain" , func (t * testing.T ) {
0 commit comments