Test ConnPool.QueryRow
This commit is contained in:
@@ -433,3 +433,25 @@ func TestConnPoolQuery(t *testing.T) {
|
|||||||
t.Fatalf("Unexpected connection pool stats: %v", stats)
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user