forked from mirror/go-sqlite3
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.
This commit is contained in:
parent
54826d9585
commit
40b65367c5
|
@ -15,6 +15,7 @@ func TestOpen(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer os.Remove("./foo.db")
|
defer os.Remove("./foo.db")
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
_, err = db.Exec("drop table foo")
|
_, err = db.Exec("drop table foo")
|
||||||
_, err = db.Exec("create table foo (id integer)")
|
_, err = db.Exec("create table foo (id integer)")
|
||||||
|
@ -35,6 +36,7 @@ func TestInsert(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer os.Remove("./foo.db")
|
defer os.Remove("./foo.db")
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
_, err = db.Exec("drop table foo")
|
_, err = db.Exec("drop table foo")
|
||||||
_, err = db.Exec("create table foo (id integer)")
|
_, err = db.Exec("create table foo (id integer)")
|
||||||
|
@ -77,6 +79,7 @@ func TestUpdate(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer os.Remove("./foo.db")
|
defer os.Remove("./foo.db")
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
_, err = db.Exec("drop table foo")
|
_, err = db.Exec("drop table foo")
|
||||||
_, err = db.Exec("create table foo (id integer)")
|
_, err = db.Exec("create table foo (id integer)")
|
||||||
|
@ -151,6 +154,7 @@ func TestDelete(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer os.Remove("./foo.db")
|
defer os.Remove("./foo.db")
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
_, err = db.Exec("drop table foo")
|
_, err = db.Exec("drop table foo")
|
||||||
_, err = db.Exec("create table foo (id integer)")
|
_, err = db.Exec("create table foo (id integer)")
|
||||||
|
@ -219,6 +223,7 @@ func TestBooleanRoundtrip(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer os.Remove("./foo.db")
|
defer os.Remove("./foo.db")
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
_, err = db.Exec("DROP TABLE foo")
|
_, err = db.Exec("DROP TABLE foo")
|
||||||
_, err = db.Exec("CREATE TABLE foo(id INTEGER, value BOOL)")
|
_, 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)
|
t.Error("Unable to query foo table:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var id int
|
var id int
|
||||||
|
@ -270,6 +276,7 @@ func TestTimestamp(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer os.Remove("./foo.db")
|
defer os.Remove("./foo.db")
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
_, err = db.Exec("DROP TABLE foo")
|
_, err = db.Exec("DROP TABLE foo")
|
||||||
_, err = db.Exec("CREATE TABLE foo(id INTEGER, ts timeSTAMP)")
|
_, 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)
|
t.Error("Unable to query foo table:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
seen := 0
|
seen := 0
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
|
@ -348,6 +356,7 @@ func TestBoolean(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
defer os.Remove("./foo.db")
|
defer os.Remove("./foo.db")
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
_, err = db.Exec("CREATE TABLE foo(id INTEGER, fbool BOOLEAN)")
|
_, err = db.Exec("CREATE TABLE foo(id INTEGER, fbool BOOLEAN)")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue