(t *testing.T, f func(t *testing.T, db *sql.DB))
| 83 | } |
| 84 | |
| 85 | func testWithAllQueryExecModes(t *testing.T, f func(t *testing.T, db *sql.DB)) { |
| 86 | for _, mode := range []pgx.QueryExecMode{ |
| 87 | pgx.QueryExecModeCacheStatement, |
| 88 | pgx.QueryExecModeCacheDescribe, |
| 89 | pgx.QueryExecModeDescribeExec, |
| 90 | pgx.QueryExecModeExec, |
| 91 | pgx.QueryExecModeSimpleProtocol, |
| 92 | } { |
| 93 | t.Run(mode.String(), |
| 94 | func(t *testing.T) { |
| 95 | config, err := pgx.ParseConfig(os.Getenv("PGX_TEST_DATABASE")) |
| 96 | require.NoError(t, err) |
| 97 | |
| 98 | config.DefaultQueryExecMode = mode |
| 99 | db := stdlib.OpenDB(*config) |
| 100 | defer func() { |
| 101 | err := db.Close() |
| 102 | require.NoError(t, err) |
| 103 | }() |
| 104 | |
| 105 | f(t, db) |
| 106 | |
| 107 | ensureDBValid(t, db) |
| 108 | }, |
| 109 | ) |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | // Do a simple query to ensure the DB is still usable. This is of less use in stdlib as the connection pool should |
| 114 | // cover broken connections. |
no test coverage detected