golang / mock

GoMock is a mocking framework for the Go programming language.
Apache License 2.0
9.3k stars 611 forks source link

implement error equality #488

Closed ymohl-cl closed 3 years ago

ymohl-cl commented 3 years ago

Fixes ##487

Description

// EqError returns a matcher that matches on equality message error (only one an error interface type)
//
// Example usage:
//   var err1 error = errors.New("content error 1")
//   var err2 error = errors.New("content error 2")
//   var errCustom1 error = CustomError.Error{msg: "content error 1"}
//   var errCustom2 error = CustomError.Error{msg: "content error 2"}
//   EqError(err1).Matches(err1) // true
//   EqError(err1).Matches(err2) // false
//   EqError(err1).Matches(errCustom1) // true
//   EqError(err1).Matches(errCustom2) // false

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you review them:

Reviewer Notes

No change, just add a Matcher and it was documented and tested
googlebot commented 3 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹī¸ Googlers: Go here for more info.

googlebot commented 3 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹī¸ Googlers: Go here for more info.

ymohl-cl commented 3 years ago

@googlebot I signed it!

googlebot commented 3 years ago

CLAs look good, thanks!

ℹī¸ Googlers: Go here for more info.

googlebot commented 3 years ago

CLAs look good, thanks!

ℹī¸ Googlers: Go here for more info.

codyoss commented 3 years ago

See discussion on linked issue.