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

Function TestNormalLifeCycle

stdlib/sql_test.go:182–219  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

180}
181
182func TestNormalLifeCycle(t *testing.T) {
183 db := openDB(t)
184 defer closeDB(t, db)
185
186 skipCockroachDB(t, db, "Server issues incorrect ParameterDescription (https://github.com/cockroachdb/cockroach/issues/60907)")
187
188 stmt := prepareStmt(t, db, "select 'foo', n from generate_series($1::int, $2::int) n")
189 defer closeStmt(t, stmt)
190
191 rows, err := stmt.Query(int32(1), int32(10))
192 require.NoError(t, err)
193
194 rowCount := int64(0)
195
196 for rows.Next() {
197 rowCount++
198
199 var s string
200 var n int64
201 err := rows.Scan(&s, &n)
202 require.NoError(t, err)
203
204 if s != "foo" {
205 t.Errorf(`Expected "foo", received "%v"`, s)
206 }
207 if n != rowCount {
208 t.Errorf("Expected %d, received %d", rowCount, n)
209 }
210 }
211 require.NoError(t, rows.Err())
212
213 require.EqualValues(t, 10, rowCount)
214
215 err = rows.Close()
216 require.NoError(t, err)
217
218 ensureDBValid(t, db)
219}
220
221func TestStmtExec(t *testing.T) {
222 db := openDB(t)

Callers

nothing calls this directly

Calls 11

openDBFunction · 0.85
closeDBFunction · 0.85
prepareStmtFunction · 0.85
closeStmtFunction · 0.85
ensureDBValidFunction · 0.85
skipCockroachDBFunction · 0.70
QueryMethod · 0.65
NextMethod · 0.65
ScanMethod · 0.65
ErrMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected