diff --git a/sqlite3_test.go b/sqlite3_test.go index 2340014..c34f0b5 100644 --- a/sqlite3_test.go +++ b/sqlite3_test.go @@ -660,43 +660,43 @@ func TestExecer(t *testing.T) { } } -//func TestQueryer(t *testing.T) { -// tempFilename := TempFilename() -// db, err := sql.Open("sqlite3", tempFilename) -// if err != nil { -// t.Fatal("Failed to open database:", err) -// } -// defer os.Remove(tempFilename) -// defer db.Close() -// -// _, err = db.Exec(` -// create table foo (id integer); -// `) -// if err != nil { -// t.Error("Failed to call db.Query:", err) -// } -// -// rows, err := db.Query(` -// insert into foo(id) values(?); -// insert into foo(id) values(?); -// insert into foo(id) values(?); -// select id from foo order by id; -// `, 3, 2, 1) -// if err != nil { -// t.Error("Failed to call db.Query:", err) -// } -// defer rows.Close() -// n := 1 -// if rows != nil { -// for rows.Next() { -// var id int -// err = rows.Scan(&id) -// if err != nil { -// t.Error("Failed to db.Query:", err) -// } -// if id != n { -// t.Error("Failed to db.Query: not matched results") -// } -// } -// } -//} +func TestQueryer(t *testing.T) { + tempFilename := TempFilename() + db, err := sql.Open("sqlite3", tempFilename) + if err != nil { + t.Fatal("Failed to open database:", err) + } + defer os.Remove(tempFilename) + defer db.Close() + + _, err = db.Exec(` + create table foo (id integer); + `) + if err != nil { + t.Error("Failed to call db.Query:", err) + } + + rows, err := db.Query(` + insert into foo(id) values(?); + insert into foo(id) values(?); + insert into foo(id) values(?); + select id from foo order by id; + `, 3, 2, 1) + if err != nil { + t.Error("Failed to call db.Query:", err) + } + defer rows.Close() + n := 1 + if rows != nil { + for rows.Next() { + var id int + err = rows.Scan(&id) + if err != nil { + t.Error("Failed to db.Query:", err) + } + if id != n { + t.Error("Failed to db.Query: not matched results") + } + } + } +}