Skip to content

Replace testhelper.Deferrer with t.Cleanup

Sami Hiltunen requested to merge smh-remove-deferrer into master

Since Go 1.14, the testing package has contained the Cleanup method which allows for deferring function to be executed at the end of the test. As the name implies, this is very suitable for cleaning up after the test. We are currently using Deferrer to do this. Now that we are on Go 1.16, we can drop Go 1.13 support as per our Go support policy and start using t.Cleanup as the minimum version is Go 1.14.

Using Cleanup allows us to reduce clutter in test code by removing all the explicit clean up calls. This can make tests easier to read and allows for composing functions easier.

Merge request reports

Loading