From 3aa81c43b1b2c5a4d79b0c27be0c5fa080247886 Mon Sep 17 00:00:00 2001 From: Nic Cope Date: Thu, 9 Sep 2021 06:48:23 +0000 Subject: [PATCH] Remove TODO about cmpopts.EquateErrors I tried to address this TODO today, but found that I kind of prefer how our implementation works. I've found from time to time while writing tests that I was accidentally wrapping my errors with the wrong context (i.e. message), which is not something the cmpopts variant tests for. Signed-off-by: Nic Cope --- pkg/test/cmp.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/test/cmp.go b/pkg/test/cmp.go index 8717674ab..a7414c1bf 100644 --- a/pkg/test/cmp.go +++ b/pkg/test/cmp.go @@ -25,13 +25,14 @@ import ( xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" ) -// TODO(negz): Replace this if a similar option is added to cmpopts per -// https://github.com/google/go-cmp/issues/89 - // EquateErrors returns true if the supplied errors are of the same type and // produce identical strings. This mirrors the error comparison behaviour of // https://github.com/go-test/deep, which most Crossplane tests targeted before // we switched to go-cmp. +// +// This differs from cmpopts.EquateErrors, which does not test for error strings +// and instead returns whether one error 'is' (in the errors.Is sense) the +// other. func EquateErrors() cmp.Option { return cmp.Comparer(func(a, b error) bool { if a == nil || b == nil {