Skip to content

Commit 947ce30

Browse files
authored
Merge pull request #59 from gliptak/rows1
Additional test for rows
2 parents 8e61072 + e4bef44 commit 947ce30

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

rows_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,3 +246,20 @@ func TestCSVRowParser(t *testing.T) {
246246
t.Fatalf("expected col2 to be nil, but got [%T]:%+v", col2, col2)
247247
}
248248
}
249+
250+
func TestWrongNumberOfValues(t *testing.T) {
251+
// Open new mock database
252+
db, mock, err := New()
253+
if err != nil {
254+
fmt.Println("error creating mock database")
255+
return
256+
}
257+
defer db.Close()
258+
defer func() {
259+
recover()
260+
}()
261+
mock.ExpectQuery("SELECT ID FROM TABLE").WithArgs(101).WillReturnRows(NewRows([]string{"ID"}).AddRow(101, "Hello"))
262+
db.Query("SELECT ID FROM TABLE", 101)
263+
// shouldn't reach here
264+
t.Error("expected panic from query")
265+
}

0 commit comments

Comments
 (0)