aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrégoire Duchêne <gduchene@awhk.org>2022-12-10 14:11:24 +0000
committerGrégoire Duchêne <gduchene@awhk.org>2022-12-10 14:11:24 +0000
commit1ec7c85d76814533a8e401f36a51a2448430d9bd (patch)
treee72a3c99fe907963d324b6179fbdfc820027ac34
parenta752a61a3aee6f3d606b6b3ede36ab1b4c510c3b (diff)
Add T.AssertErrorAs
-rw-r--r--testing.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/testing.go b/testing.go
index c8bd66a..2b91a72 100644
--- a/testing.go
+++ b/testing.go
@@ -40,6 +40,16 @@ func (t *T) AssertEqual(exp, actual any) bool {
return false
}
+func (t *T) AssertErrorAs(target any, err error) bool {
+ t.Helper()
+
+ if errors.As(err, target) {
+ return true
+ }
+ t.Errorf("\nexpected error chain to contain %#v, got %#v", target, err)
+ return false
+}
+
func (t *T) AssertErrorIs(target, err error) bool {
t.Helper()