mirror of
https://github.com/zhashkevych/go-sqlxmock.git
synced 2024-11-24 08:12:13 +02:00
Additional test for rows
This commit is contained in:
parent
8e610725b3
commit
e4bef44c55
17
rows_test.go
17
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")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user