mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
exp/sql: close Rows on EOF
Fixes #2624 R=rsc CC=golang-dev https://golang.org/cl/5530068
This commit is contained in:
parent
25cf9bdea6
commit
4435c8bf2a
3 changed files with 31 additions and 11 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue