You've already forked go-sqlxmock
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:
19
rows.go
19
rows.go
@ -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 {
|
||||
|
Reference in New Issue
Block a user