From c11c7c7ad5a55f08b7350a3073e96cc37ec8853d Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Wed, 9 Jul 2014 08:34:16 -0500 Subject: [PATCH] Test ConnPool.QueryRow --- conn_pool_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/conn_pool_test.go b/conn_pool_test.go index 1d364253..1dde72bd 100644 --- a/conn_pool_test.go +++ b/conn_pool_test.go @@ -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) + } +}