Skip to content

Update testify package to version supporting errors.Is/As directly

Pedro Pombeiro requested to merge pedropombeiro/assert.erroris into master

What does this MR do?

Updates the github.com/stretchr/testify package to version that natively supports errors.Is and errors.As!

I basically ran the following commands:

go get -u github.com/stretchr/testify@v1.6.2-0.20200720104044-95a9d909e987
go mod tidy
make tests

Why was this MR needed?

Testify finally introduced support for errors.Is() and errors.As() in the assert and require package! Which is an awesome replacement for our hacky and ugly assert.True(t, errors.Is(err, target), "... %T, %T", err, target).

But... The last tagged version of the package is v1.6.1, tagged at 2020-06-05. While the ErrorsIs/ErrorsAs change was merged at 2020-06-20. And neither v1.6.2 nor v1.7.0 was tagged since then 🙂

Looking at the changes between v1.6.1 and the commit that merges the errors wrapper support there are mostly:

  • documentation and testify internal testing updates,
  • one update in how values comparison works (which would be a change "affecting" the users of the package),
  • and of course the addition of errors.Is() and errors.As() support.

I think it should be safe to use the commit-based version and updating to it without waiting for next tagged one. Of course when 1.6.2 or 1.7.0 will be released I'm fully into updating what we use again, but until then... let's use what we have 🙂

This MR also replaces all assertion.ErrorIs with the native ones.

What's the best way to test this MR?

What are the relevant issue numbers?

Closes #56 (closed)

Edited by Pedro Pombeiro

Merge request reports