Test ConnPool.QueryRow

scan-io
Jack Christensen 2014-07-09 08:34:16 -05:00
parent d7b402cd65
commit c11c7c7ad5
1 changed files with 22 additions and 0 deletions

View File

@ -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)
}
}