mirror of https://github.com/jackc/pgx.git
Test ConnPool.QueryRow
parent
d7b402cd65
commit
c11c7c7ad5
|
@ -433,3 +433,25 @@ func TestConnPoolQuery(t *testing.T) {
|
|||
t.Fatalf("Unexpected connection pool stats: %v", stats)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConnPoolQueryRow(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pool := createConnPool(t, 2)
|
||||
defer pool.Close()
|
||||
|
||||
var n int32
|
||||
err := pool.QueryRow("select 40+$1", 2).Scan(&n)
|
||||
if err != nil {
|
||||
t.Fatalf("pool.QueryRow Scan failed: %v", err)
|
||||
}
|
||||
|
||||
if n != 42 {
|
||||
t.Errorf("Expected 42, got %d", n)
|
||||
}
|
||||
|
||||
stats := pool.Stat()
|
||||
if stats.CurrentConnections != 1 || stats.AvailableConnections != 1 {
|
||||
t.Fatalf("Unexpected connection pool stats: %v", stats)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue