-
Notifications
You must be signed in to change notification settings - Fork 562
chore(test): Added CustomMatcher for asserting on k8 errors for better readability #1730
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
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: harishsurf The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This PR failed 1 out of 1 times with 1 individual failed tests and 4 skipped tests. A test is considered flaky if failed on multiple commits. totaltestcount: 1
|
/hold |
The string equality matching here is pretty confusing, and it sort of reverses the way Gomega assertions are written -- that is, the argument to I was imagining a custom GomegaMatcher implementation, so test authors could write an assertion something like |
return WithTransform(func(f func(e error) bool) string { | ||
var errFuncName string | ||
if f(actualError) { | ||
errFuncName = runtime.FuncForPC(reflect.ValueOf(f).Pointer()).Name() |
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.
https://golang.org/pkg/runtime/#FuncForPC can also return nil, which would cause a panic and force users to stop and understand the implementation of this function. Magic like reflection needs to be extra robust because it's so much harder to understand when it breaks.
Closing this PR as it's idle and won't be merged as-is. I'm happy to discuss testing quality-of-life improvements with you any time if you're interested in picking it back up. |
Description of the change:
This PR is a result of discussion from here
Reviewer Checklist
/docs