diff options
| author | Grégoire Duchêne <gduchene@awhk.org> | 2022-12-10 14:11:24 +0000 |
|---|---|---|
| committer | Grégoire Duchêne <gduchene@awhk.org> | 2022-12-10 14:11:24 +0000 |
| commit | 1ec7c85d76814533a8e401f36a51a2448430d9bd (patch) | |
| tree | e72a3c99fe907963d324b6179fbdfc820027ac34 | |
| parent | a752a61a3aee6f3d606b6b3ede36ab1b4c510c3b (diff) | |
Add T.AssertErrorAs
| -rw-r--r-- | testing.go | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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() |
