From 4256834a5f656a2b6d8b8ee1e05ac7048b3028a0 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 29 Aug 2024 11:09:08 +0200 Subject: [PATCH] assert, assert/cmp: un-deprecate assert.ErrorType for now Commit 043b5794574c597257f7801eb14456aba5452849 deprecated these functions, marking assert.ErrorIs as a replacement. Unfortunately, assert.ErrorIs is not a drop-in replacement for various situations, or requires quite some additional boilerplating to be used. This patch reverts the deprecation for now, but keeps recommendations in place to consider ErrorIs for situations that allow it. Signed-off-by: Sebastiaan van Stijn --- assert/assert.go | 2 -- assert/cmp/compare.go | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/assert/assert.go b/assert/assert.go index c418bd0..ae62cef 100644 --- a/assert/assert.go +++ b/assert/assert.go @@ -284,8 +284,6 @@ func ErrorContains(t TestingT, err error, substring string, msgAndArgs ...interf // must be called from the goroutine running the test function, not from other // goroutines created during the test. Use [Check] with [cmp.ErrorType] from other // goroutines. -// -// Deprecated: Use [ErrorIs] func ErrorType(t TestingT, err error, expected interface{}, msgAndArgs ...interface{}) { if ht, ok := t.(helperT); ok { ht.Helper() diff --git a/assert/cmp/compare.go b/assert/cmp/compare.go index 3ced3de..a7507e6 100644 --- a/assert/cmp/compare.go +++ b/assert/cmp/compare.go @@ -286,6 +286,7 @@ func isNil(obj interface{}, msgFunc func(reflect.Value) string) Comparison { } // ErrorType succeeds if err is not nil and is of the expected type. +// New code should use [ErrorIs] instead. // // Expected can be one of: // @@ -306,8 +307,6 @@ func isNil(obj interface{}, msgFunc func(reflect.Value) string) Comparison { // reflect.Type // // Fails if err does not implement the [reflect.Type]. -// -// Deprecated: Use [ErrorIs] func ErrorType(err error, expected interface{}) Comparison { return func() Result { switch expectedType := expected.(type) {