1
0
mirror of https://github.com/DATA-DOG/go-sqlmock.git synced 2025-06-23 00:17:47 +02:00

improves error messages, closes #77

This commit is contained in:
gedi
2017-04-26 09:56:02 +03:00
parent a32ff1cda1
commit 18ab7ac1c7
5 changed files with 51 additions and 18 deletions

13
rows.go
View File

@ -49,6 +49,10 @@ func (rs *rowSets) Next(dest []driver.Value) error {
// transforms to debuggable printable string
func (rs *rowSets) String() string {
if rs.empty() {
return "with empty rows"
}
msg := "should return rows:\n"
if len(rs.sets) == 1 {
for n, row := range rs.sets[0].rows {
@ -65,6 +69,15 @@ func (rs *rowSets) String() string {
return strings.TrimSpace(msg)
}
func (rs *rowSets) empty() bool {
for _, set := range rs.sets {
if len(set.rows) > 0 {
return false
}
}
return true
}
// Rows is a mocked collection of rows to
// return for Query result
type Rows struct {