From e22d46e188cb08f1c067b30133ab35884fe2123a Mon Sep 17 00:00:00 2001 From: tech-sam Date: Tue, 3 Dec 2024 20:27:10 +0100 Subject: [PATCH] Use errors.Is for error comparison in assertError helper --- maps/v2/dictionary_test.go | 3 ++- maps/v3/dictionary_test.go | 3 ++- maps/v4/dictionary_test.go | 3 ++- maps/v5/dictionary_test.go | 3 ++- maps/v6/dictionary_test.go | 3 ++- maps/v7/dictionary_test.go | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/maps/v2/dictionary_test.go b/maps/v2/dictionary_test.go index 2a03db079..9b7a5efff 100644 --- a/maps/v2/dictionary_test.go +++ b/maps/v2/dictionary_test.go @@ -1,6 +1,7 @@ package main import ( + "errors" "testing" ) @@ -32,7 +33,7 @@ func assertStrings(t testing.TB, got, want string) { func assertError(t testing.TB, got, want error) { t.Helper() - if got != want { + if !errors.Is(got, want) { t.Errorf("got error %q want %q", got, want) } } diff --git a/maps/v3/dictionary_test.go b/maps/v3/dictionary_test.go index 2ccc4e0ae..6c7b90c6e 100644 --- a/maps/v3/dictionary_test.go +++ b/maps/v3/dictionary_test.go @@ -1,6 +1,7 @@ package main import ( + "errors" "testing" ) @@ -42,7 +43,7 @@ func assertStrings(t testing.TB, got, want string) { func assertError(t testing.TB, got, want error) { t.Helper() - if got != want { + if !errors.Is(got, want) { t.Errorf("got error %q want %q", got, want) } } diff --git a/maps/v4/dictionary_test.go b/maps/v4/dictionary_test.go index f39c71faa..dc5417df5 100644 --- a/maps/v4/dictionary_test.go +++ b/maps/v4/dictionary_test.go @@ -1,6 +1,7 @@ package main import ( + "errors" "testing" ) @@ -55,7 +56,7 @@ func assertStrings(t testing.TB, got, want string) { func assertError(t testing.TB, got, want error) { t.Helper() - if got != want { + if !errors.Is(got, want) { t.Errorf("got error %q want %q", got, want) } } diff --git a/maps/v5/dictionary_test.go b/maps/v5/dictionary_test.go index e6503117d..ccb408c42 100644 --- a/maps/v5/dictionary_test.go +++ b/maps/v5/dictionary_test.go @@ -1,6 +1,7 @@ package main import ( + "errors" "testing" ) @@ -66,7 +67,7 @@ func assertStrings(t testing.TB, got, want string) { func assertError(t testing.TB, got, want error) { t.Helper() - if got != want { + if !errors.Is(got, want) { t.Errorf("got error %q want %q", got, want) } } diff --git a/maps/v6/dictionary_test.go b/maps/v6/dictionary_test.go index 119499fae..58def28c8 100644 --- a/maps/v6/dictionary_test.go +++ b/maps/v6/dictionary_test.go @@ -1,6 +1,7 @@ package main import ( + "errors" "testing" ) @@ -78,7 +79,7 @@ func assertStrings(t testing.TB, got, want string) { func assertError(t testing.TB, got, want error) { t.Helper() - if got != want { + if !errors.Is(got, want) { t.Errorf("got error %q want %q", got, want) } } diff --git a/maps/v7/dictionary_test.go b/maps/v7/dictionary_test.go index 15b8703d4..61017e168 100644 --- a/maps/v7/dictionary_test.go +++ b/maps/v7/dictionary_test.go @@ -1,6 +1,7 @@ package main import ( + "errors" "testing" ) @@ -102,7 +103,7 @@ func assertStrings(t testing.TB, got, want string) { func assertError(t testing.TB, got, want error) { t.Helper() - if got != want { + if !errors.Is(got, want) { t.Errorf("got error %q want %q", got, want) } }