forked from slack-go/slack
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor views test using errors.Is introduce xerrors.Is instead of errors.Is Revert "Refactor views test using errors.Is" This reverts commit f09d336.
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package errorsx | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
) | ||
|
||
func TestIs(t *testing.T) { | ||
test := func(receiver String, target error, expected bool) { | ||
if result := receiver.Is(target); result != expected { | ||
t.Errorf(`expected "%s Is %s" should be %t , got: %t`, receiver, target, expected, result) | ||
} | ||
} | ||
|
||
test(String("test error"), errors.New("test error"), true) | ||
test(String("test error"), errors.New("different error"), false) | ||
test(String("test error"), nil, false) | ||
} |