-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mark test.EquateErrors as deprecated #529
base: main
Are you sure you want to change the base?
Conversation
See crossplane/crossplane#4514 for context. We can't remove this (it would be a breaking API change) but I want to discourage and redirect folks. Signed-off-by: Nic Cope <nicc@rk0n.org>
Converting to draft because I forgot I had to update all the uses in this repo. 😆 |
To avoid doing a whole bunch of string comparison in unit tests, we also switch to using cmpopts.EquateErrors. Signed-off-by: Nic Cope <nicc@rk0n.org>
This way code in policies.go has its tests in policies_test.go, not reconciler_test.go. Signed-off-by: Nic Cope <nicc@rk0n.org>
@@ -214,7 +202,7 @@ func SecretToDeleteMustBeOwnedBy(so metav1.Object) store.DeleteOption { | |||
|
|||
func secretMustBeOwnedBy(so metav1.Object, secret *store.Secret) error { | |||
if secret.Metadata == nil || secret.Metadata.GetOwnerUID() != string(so.GetUID()) { | |||
return errors.Errorf(errFmtNotOwnedBy, string(so.GetUID())) | |||
return errors.Errorf("existing secret is not woned by UID %q", string(so.GetUID())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return errors.Errorf("existing secret is not woned by UID %q", string(so.GetUID())) | |
return errors.Errorf("existing secret is not owned by UID %q", string(so.GetUID())) |
@@ -87,7 +84,8 @@ func TestManagerConnectStore(t *testing.T) { | |||
}, | |||
}, | |||
want: want{ | |||
err: errors.Wrapf(kerrors.NewNotFound(schema.GroupResource{}, fakeConfig), errGetStoreConfig), | |||
// TODO(negz): Can we test that this is kerrors.NewNotFound? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried implementing a custom EquateErrors based on errors.As
, but unfortunately I couldn't make it work, so I guess we're stuck with cmptopts.AnyError
.
This is approved, so if this PR is still relevant could we rebase and merge? |
Description of your changes
We can't remove this (it would be a breaking API change) but I want to discourage and redirect folks.
See crossplane/crossplane#4514 for context and more discussion. I've also updated this repo to follow the new pattern proposed in that issue, so it acts as an example of how tests might look if we choose to adopt it.
I have:
make reviewable test
to ensure this PR is ready for review.How has this code been tested