diff --git a/pgxmock.go b/pgxmock.go index 377c7a5..397b316 100644 --- a/pgxmock.go +++ b/pgxmock.go @@ -554,25 +554,22 @@ func findExpectationFunc[ET expectationType[t], t any](c *pgxmock, method string fulfilled++ continue } - if expected, ok = next.(ET); ok { - err = cmp(expected) - if err == nil { + if err = cmp(expected); err == nil { break } } + expected = nil + next.Unlock() if c.ordered { - if (!ok || err != nil) && !next.required() { - next.Unlock() + if !next.required() { continue } - next.Unlock() if err != nil { return nil, err } return nil, fmt.Errorf("call to method %s, was not expected, next expectation is: %s", method, next) } - next.Unlock() } if expected == nil {