From 40b65367c59385f3458b6876082478e276b4b76b Mon Sep 17 00:00:00 2001 From: cds Date: Tue, 11 Sep 2012 09:23:21 -0500 Subject: [PATCH] Added missing db.Close() and rows.Close() calls; fixes tests on vmhgfs filesystems. Individual tests were never successfully removing 'foo.db' (the error was ignored), which caused everything but the first test to fail on my vmhgfs filesystem. Adding the relevant defer db.Close() and rows.Close() calls fixed the leaks, enabling os.Remove() to work. --- sqlite3_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sqlite3_test.go b/sqlite3_test.go index 181f59b..a77dd6e 100644 --- a/sqlite3_test.go +++ b/sqlite3_test.go @@ -15,6 +15,7 @@ func TestOpen(t *testing.T) { return } defer os.Remove("./foo.db") + defer db.Close() _, err = db.Exec("drop table foo") _, err = db.Exec("create table foo (id integer)") @@ -35,6 +36,7 @@ func TestInsert(t *testing.T) { return } defer os.Remove("./foo.db") + defer db.Close() _, err = db.Exec("drop table foo") _, err = db.Exec("create table foo (id integer)") @@ -77,6 +79,7 @@ func TestUpdate(t *testing.T) { return } defer os.Remove("./foo.db") + defer db.Close() _, err = db.Exec("drop table foo") _, err = db.Exec("create table foo (id integer)") @@ -151,6 +154,7 @@ func TestDelete(t *testing.T) { return } defer os.Remove("./foo.db") + defer db.Close() _, err = db.Exec("drop table foo") _, err = db.Exec("create table foo (id integer)") @@ -219,6 +223,7 @@ func TestBooleanRoundtrip(t *testing.T) { return } defer os.Remove("./foo.db") + defer db.Close() _, err = db.Exec("DROP TABLE foo") _, err = db.Exec("CREATE TABLE foo(id INTEGER, value BOOL)") @@ -244,6 +249,7 @@ func TestBooleanRoundtrip(t *testing.T) { t.Error("Unable to query foo table:", err) return } + defer rows.Close() for rows.Next() { var id int @@ -270,6 +276,7 @@ func TestTimestamp(t *testing.T) { return } defer os.Remove("./foo.db") + defer db.Close() _, err = db.Exec("DROP TABLE foo") _, err = db.Exec("CREATE TABLE foo(id INTEGER, ts timeSTAMP)") @@ -303,6 +310,7 @@ func TestTimestamp(t *testing.T) { t.Error("Unable to query foo table:", err) return } + defer rows.Close() seen := 0 for rows.Next() { @@ -348,6 +356,7 @@ func TestBoolean(t *testing.T) { } defer os.Remove("./foo.db") + defer db.Close() _, err = db.Exec("CREATE TABLE foo(id INTEGER, fbool BOOLEAN)") if err != nil {