aboutsummaryrefslogtreecommitdiff
path: root/sqlite3_test.go
diff options
context:
space:
mode:
authormattn <mattn.jp@gmail.com>2013-09-09 12:28:34 +0900
committermattn <mattn.jp@gmail.com>2013-09-09 12:28:34 +0900
commit77ebf39cf9610451887667b4cc6415e3aae6f98c (patch)
tree5c973b9d9fc092663b66217e96060cda099a93f9 /sqlite3_test.go
parentFixes test (diff)
downloadgolite-77ebf39cf9610451887667b4cc6415e3aae6f98c.tar.gz
golite-77ebf39cf9610451887667b4cc6415e3aae6f98c.tar.xz
Fixes Execer/Queryer
Diffstat (limited to 'sqlite3_test.go')
-rw-r--r--sqlite3_test.go34
1 files changed, 18 insertions, 16 deletions
diff --git a/sqlite3_test.go b/sqlite3_test.go
index 5da83f6..8a95314 100644
--- a/sqlite3_test.go
+++ b/sqlite3_test.go
@@ -591,9 +591,9 @@ func TestExecer(t *testing.T) {
_, err = db.Exec(`
create table foo (id integer);
- insert into foo values(1);
- insert into foo values(2);
- insert into foo values(3);
+ insert into foo(id) values(1);
+ insert into foo(id) values(2);
+ insert into foo(id) values(3);
`)
if err != nil {
t.Error("Failed to call db.Exec:", err)
@@ -614,24 +614,26 @@ func TestQueryer(t *testing.T) {
rows, err := db.Query(`
create table foo (id integer);
- insert into foo values(1);
- insert into foo values(2);
- insert into foo values(3);
+ 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.Exec:", err)
+ t.Error("Failed to call db.Query:", 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")
+ 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")
+ }
}
}
}