Skip to content

Commit

Permalink
assert, assert/cmp: un-deprecate assert.ErrorType for now
Browse files Browse the repository at this point in the history
Commit 043b579 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 <github@gone.nl>
  • Loading branch information
thaJeztah committed Aug 29, 2024
1 parent 9aa7888 commit 4256834
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
2 changes: 0 additions & 2 deletions assert/assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions assert/cmp/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
//
Expand All @@ -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) {
Expand Down

0 comments on commit 4256834

Please sign in to comment.