onsi / gomega

Ginkgo's Preferred Matcher Library
http://onsi.github.io/gomega/
MIT License
2.18k stars 284 forks source link

compare unwrapped errors using DeepEqual #617

Closed tareksha closed 1 year ago

tareksha commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

@onsi done

onsi commented 1 year ago

perfect, thanks!

tareksha commented 1 year ago

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

onsi commented 1 year ago

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

onsi commented 1 year ago

this just shipped in 1.25.0