@@ -44,13 +44,28 @@ func TestConnectConfig(t *testing.T) {
4444func TestParseConfigExtractsPoolArguments (t * testing.T ) {
4545 t .Parallel ()
4646
47- config , err := pgxpool .ParseConfig ("pool_max_conns=42 pool_min_conns=1 pool_min_idle_conns=2" )
47+ config , err := pgxpool .ParseConfig ("pool_max_conns=42 pool_min_conns=1 pool_min_idle_conns=2 pool_ping_timeout=250ms " )
4848 assert .NoError (t , err )
4949 assert .EqualValues (t , 42 , config .MaxConns )
5050 assert .EqualValues (t , 1 , config .MinConns )
5151 assert .EqualValues (t , 2 , config .MinIdleConns )
52+ assert .Equal (t , 250 * time .Millisecond , config .PingTimeout )
53+
54+ // Anything left in RuntimeParams is sent to the server as a startup parameter, which makes every connection fail
55+ // with "unrecognized configuration parameter".
5256 assert .NotContains (t , config .ConnConfig .Config .RuntimeParams , "pool_max_conns" )
5357 assert .NotContains (t , config .ConnConfig .Config .RuntimeParams , "pool_min_conns" )
58+ assert .NotContains (t , config .ConnConfig .Config .RuntimeParams , "pool_min_idle_conns" )
59+ assert .NotContains (t , config .ConnConfig .Config .RuntimeParams , "pool_ping_timeout" )
60+
61+ config , err = pgxpool .ParseConfig ("" )
62+ assert .NoError (t , err )
63+ assert .Zero (t , config .PingTimeout )
64+
65+ for _ , v := range []string {"abc" , "250" } {
66+ _ , err := pgxpool .ParseConfig ("pool_ping_timeout=" + v )
67+ assert .Errorf (t , err , "pool_ping_timeout=%s should be rejected" , v )
68+ }
5469}
5570
5671func TestConstructorIgnoresContext (t * testing.T ) {
0 commit comments