1
0
mirror of https://github.com/DATA-DOG/go-sqlmock.git synced 2025-03-19 20:57:50 +02:00

Fix ExpectedExec Stringer implementation

Sometimes the result is incorrectly set, so the cast that takes place in
the String() method returns nil.
This commit is contained in:
Alan D. Cabrera 2021-01-15 07:02:35 -08:00
parent c35a79d518
commit ad48e464a0

View File

@ -230,12 +230,13 @@ func (e *ExpectedExec) String() string {
}
if e.result != nil {
res, _ := e.result.(*result)
msg += "\n - should return Result having:"
msg += fmt.Sprintf("\n LastInsertId: %d", res.insertID)
msg += fmt.Sprintf("\n RowsAffected: %d", res.rowsAffected)
if res.err != nil {
msg += fmt.Sprintf("\n Error: %s", res.err)
if res, ok := e.result.(*result); ok {
msg += "\n - should return Result having:"
msg += fmt.Sprintf("\n LastInsertId: %d", res.insertID)
msg += fmt.Sprintf("\n RowsAffected: %d", res.rowsAffected)
if res.err != nil {
msg += fmt.Sprintf("\n Error: %s", res.err)
}
}
}