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

asserts ordinal argument position, fixes expected query error message

This commit is contained in:
gedi
2017-02-16 22:33:12 +02:00
parent 53b2cd1534
commit a00b6aa80e
4 changed files with 22 additions and 9 deletions

19
rows.go
View File

@ -3,6 +3,7 @@ package sqlmock
import (
"database/sql/driver"
"encoding/csv"
"fmt"
"io"
"strings"
)
@ -46,6 +47,24 @@ func (rs *rowSets) Next(dest []driver.Value) error {
return r.nextErr[r.pos-1]
}
// transforms to debuggable printable string
func (rs *rowSets) String() string {
msg := "should return rows:\n"
if len(rs.sets) == 1 {
for n, row := range rs.sets[0].rows {
msg += fmt.Sprintf(" row %d - %+v\n", n, row)
}
return strings.TrimSpace(msg)
}
for i, set := range rs.sets {
msg += fmt.Sprintf(" result set: %d\n", i)
for n, row := range set.rows {
msg += fmt.Sprintf(" row %d - %+v\n", n, row)
}
}
return strings.TrimSpace(msg)
}
// Rows is a mocked collection of rows to
// return for Query result
type Rows struct {