exp/sql: close Rows on EOF

Fixes #2624

R=rsc
CC=golang-dev
https://golang.org/cl/5530068
This commit is contained in:
Brad Fitzpatrick 2012-01-10 12:51:27 -08:00
parent 25cf9bdea6
commit 4435c8bf2a
3 changed files with 31 additions and 11 deletions

View file

@ -10,8 +10,10 @@ import (
"testing"
)
const fakeDBName = "foo"
func newTestDB(t *testing.T, name string) *DB {
db, err := Open("test", "foo")
db, err := Open("test", fakeDBName)
if err != nil {
t.Fatalf("Open: %v", err)
}
@ -73,6 +75,12 @@ func TestQuery(t *testing.T) {
if !reflect.DeepEqual(got, want) {
t.Logf(" got: %#v\nwant: %#v", got, want)
}
// And verify that the final rows.Next() call, which hit EOF,
// also closed the rows connection.
if n := len(db.freeConn); n != 1 {
t.Errorf("free conns after query hitting EOF = %d; want 1", n)
}
}
func TestRowsColumns(t *testing.T) {