2
0

Introduce new pool setting: LazyConnect

This commit is contained in:
georgysavva
2020-04-03 10:28:05 +03:00
parent bc4586ac6f
commit 5d453485a9
3 changed files with 30 additions and 8 deletions
+17
View File
@@ -41,6 +41,23 @@ func TestConnectCancel(t *testing.T) {
assert.Equal(t, context.Canceled, err)
}
func TestLazyConnect(t *testing.T) {
t.Parallel()
config, err := pgxpool.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
assert.NoError(t, err)
config.LazyConnect = true
ctx, cancel := context.WithCancel(context.Background())
cancel()
pool, err := pgxpool.ConnectConfig(ctx, config)
assert.NoError(t, err)
_, err = pool.Exec(ctx, "SELECT 1")
assert.Equal(t, context.Canceled, err)
}
func TestConnectConfigRequiresConnConfigFromParseConfig(t *testing.T) {
t.Parallel()