Skip to content

Commit

Permalink
Fix ExpectedExec Stringer implementation
Browse files Browse the repository at this point in the history
Sometimes the result is incorrectly set, so the cast that takes place in
the String() method returns nil.
  • Loading branch information
maguro committed Jan 15, 2021
1 parent c35a79d commit ad48e46
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions expectations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

Expand Down

0 comments on commit ad48e46

Please # to comment.