From b9c9cb1ae6c5f144d02f4bcdf4a63020a8925fb5 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Sun, 30 Jun 2024 16:43:36 +0200 Subject: [PATCH] error-compare: allow ErrorContains and ErrorEqual --- CONTRIBUTING.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 29149427..c0afbb3f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -172,14 +172,15 @@ Describe a new checker in [checkers section](./README.md#checkers). ### error-compare ```go -❌ assert.ErrorContains(t, err, "not found") - assert.EqualError(t, err, "user not found") +❌ assert.Contains(t, err.Error(), "not found") assert.Equal(t, err.Error(), "user not found") assert.Equal(t, err, errSentinel) // Through `reflect.DeepEqual` causes error strings to be compared. assert.NotEqual(t, err, errSentinel) // etc. -✅ assert.ErrorIs(t, err, ErrUserNotFound) +✅ assert.ErrorContains(t, err, "not found") + assert.EqualError(t, err, "user not found") + assert.ErrorIs(t, err, ErrUserNotFound) ``` **Autofix**: false.