Skip to content

Commit f1eef49

Browse files
ohwgilesmattn
authored andcommitted
TestQueryer: actually check Rows returned
Fixes a test which did not correctly exercise the multi-statement Queryer functionality
1 parent a2e94c9 commit f1eef49

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

sqlite3_test.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,17 +1080,19 @@ func TestQueryer(t *testing.T) {
10801080
}
10811081
defer rows.Close()
10821082
n := 1
1083-
if rows != nil {
1084-
for rows.Next() {
1085-
var id int
1086-
err = rows.Scan(&id)
1087-
if err != nil {
1088-
t.Error("Failed to db.Query:", err)
1089-
}
1090-
if id != n {
1091-
t.Error("Failed to db.Query: not matched results")
1092-
}
1083+
for rows.Next() {
1084+
var id int
1085+
err = rows.Scan(&id)
1086+
if err != nil {
1087+
t.Error("Failed to db.Query:", err)
10931088
}
1089+
if id != n {
1090+
t.Error("Failed to db.Query: not matched results")
1091+
}
1092+
n = n + 1
1093+
}
1094+
if n != 3 {
1095+
t.Errorf("Expected 3 rows but retrieved %v", n-1)
10941096
}
10951097
}
10961098

0 commit comments

Comments
 (0)