From e4bef44c557bbf3fbb4af748d96e45b5a13dcc27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Lipt=C3=A1k?= Date: Sun, 27 Nov 2016 20:14:41 -0500 Subject: [PATCH] Additional test for rows --- rows_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/rows_test.go b/rows_test.go index 8f11f4d..56e834e 100644 --- a/rows_test.go +++ b/rows_test.go @@ -246,3 +246,20 @@ func TestCSVRowParser(t *testing.T) { t.Fatalf("expected col2 to be nil, but got [%T]:%+v", col2, col2) } } + +func TestWrongNumberOfValues(t *testing.T) { + // Open new mock database + db, mock, err := New() + if err != nil { + fmt.Println("error creating mock database") + return + } + defer db.Close() + defer func() { + recover() + }() + mock.ExpectQuery("SELECT ID FROM TABLE").WithArgs(101).WillReturnRows(NewRows([]string{"ID"}).AddRow(101, "Hello")) + db.Query("SELECT ID FROM TABLE", 101) + // shouldn't reach here + t.Error("expected panic from query") +}