MCPcopy
hub / github.com/jackc/pgx / testWithAllQueryExecModes

Function testWithAllQueryExecModes

stdlib/sql_test.go:85–111  ·  view source on GitHub ↗
(t *testing.T, f func(t *testing.T, db *sql.DB))

Source from the content-addressed store, hash-verified

83}
84
85func 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.

Callers 15

TestConnExecFunction · 0.85
TestConnQueryFunction · 0.85
TestConnConcurrencyFunction · 0.85
TestConnQueryNullFunction · 0.85
TestConnQueryFailureFunction · 0.85
TestConnQueryScanGoArrayFunction · 0.85
TestConnQueryScanArrayFunction · 0.85
TestConnQueryScanRangeFunction · 0.85

Calls 5

OpenDBFunction · 0.92
ensureDBValidFunction · 0.85
CloseMethod · 0.65
RunMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected