Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compare unwrapped errors using DeepEqual #617

Merged
merged 3 commits into from
Jan 14, 2023
Merged

Conversation

tareksha
Copy link
Contributor

Currently when the actual error is check by MatchError, it matches in two cases:

  1. The built-in errors.Is(..) returns true
  2. the actual error deep-equals the matcher error

this change expands the second case and performs DeepEqual on each error in the chain of unwrapping. This allows matching complex errors that are wrapped, for example:

err := fmt.Errorf("internal error: %w", MyKeyError{Key: "alice})

Expect(err).To(MatchError(MyKeyError{Key: "alice}))

@onsi
Copy link
Owner

onsi commented Jan 14, 2023

Looks good to me - thanks!

Would you be up for updating the docs here:

https://onsi.github.io/gomega/#matcherrorexpected-interface

(it's the index.md file in the docs directory)

@tareksha
Copy link
Contributor Author

@onsi done

@onsi onsi merged commit aaeaa5d into onsi:master Jan 14, 2023
@onsi
Copy link
Owner

onsi commented Jan 14, 2023

perfect, thanks!

@tareksha tareksha deleted the uwrap_deepequal branch January 14, 2023 19:09
@tareksha
Copy link
Contributor Author

@onsi thanks for accepting the change. when is this expected to be released?

@onsi
Copy link
Owner

onsi commented Jan 16, 2023

hey - I'll cut a release once #619 gets merged in.

@onsi
Copy link
Owner

onsi commented Jan 17, 2023

this just shipped in 1.25.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants