1
0
mirror of https://github.com/zhashkevych/go-sqlxmock.git synced 2025-06-12 21:47:29 +02:00

return error instead panic if argument reflection types are not matching

This commit is contained in:
gedi
2014-08-16 12:48:11 +03:00
parent c8ac9dfd29
commit e36ad8d068
3 changed files with 36 additions and 8 deletions

View File

@ -420,3 +420,19 @@ func TestRowBuilderAndNilTypes(t *testing.T) {
t.Errorf("error '%s' was not expected while closing the database", err)
}
}
func TestArgumentReflectValueTypeError(t *testing.T) {
db, err := sql.Open("mock", "")
if err != nil {
t.Errorf("an error '%s' was not expected when opening a stub database connection", err)
}
rs := NewRows([]string{"id"}).AddRow(1)
ExpectQuery("SELECT (.+) FROM sales").WithArgs(5.5).WillReturnRows(rs)
_, err = db.Query("SELECT * FROM sales WHERE x = ?", 5)
if err == nil {
t.Error("Expected error, but got none")
}
}