From fc9f8cab248885e69f9eef63f5ffb7f8010c46e0 Mon Sep 17 00:00:00 2001 From: mattn Date: Mon, 9 Sep 2013 11:27:04 +0900 Subject: [PATCH] Fixes test --- sqlite3_test.go | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/sqlite3_test.go b/sqlite3_test.go index 6c0487e..5da83f6 100644 --- a/sqlite3_test.go +++ b/sqlite3_test.go @@ -590,7 +590,7 @@ func TestExecer(t *testing.T) { defer db.Close() _, err = db.Exec(` - create table foo (id integer)"); + create table foo (id integer); insert into foo values(1); insert into foo values(2); insert into foo values(3); @@ -598,5 +598,41 @@ func TestExecer(t *testing.T) { if err != nil { t.Error("Failed to call db.Exec:", err) } + if err != nil { + t.Error("Failed to call res.RowsAffected:", err) + } +} + +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() + + rows, err := db.Query(` + create table foo (id integer); + insert into foo values(1); + insert into foo values(2); + insert into foo values(3); + select id from foo order by id; + `) + if err != nil { + t.Error("Failed to call db.Exec:", err) + } + defer rows.Close() + n := 1 + 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") + } + } }