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
Add AppendInvoke convenience wrapper #47
Conversation
Codecov Report
@@ Coverage Diff @@
## master #47 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 102 105 +3
=========================================
+ Hits 102 105 +3
Continue to review full report at Codecov.
|
97f8485
to
42dee48
Compare
This takes a pass over the provided documentation to add more examples and explanations.
This adds more information about AppendInvoke to the package level documentation.
This simplifies the tests for multierr.AppendInvoke with multierr.Close. Primarily, this moves the shared logic of building a mock closer and using multierr.Close into the test body rather than in individual test cases.
Thanks for the contribution, @baez90! This is generally looking pretty good. CC @prashantv |
Thanks for your work on the documentation! |
@prashantv any chance to get a review any time soon? I'd love to be able to use this 😄 |
} | ||
|
||
func TestAppendInvokeClose(t *testing.T) { | ||
tests := []struct { |
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.
looks like these cases are exactly the same as AppendInvoke
, should we instead share the cases? Then we could have the same cases be used across all variances:
- an
Invoke
function that returns the specified error - an object implementing
Invoker
that returns the specified error Closer
- possible also with
AppendInvokeFn
if we add that method
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.
Interesting idea, unfortunately this is not directly possible.
You would need to recreate the inputs for every case that would 'reuse' the input because the into
modifies the original input and I'm not aware of any good solution how to handle this without introducing either weird side effects or rather complex test input generation.
defer func() { | ||
fmt.Println(err) | ||
}() |
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.
optional: I wonder if we should do a full file example instead, as it may be easier to see the print from a separate function that calls a function using AppendInvoke
. It's a little easier to think of this as the result the caller sees IMO
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.
you mean moving this to a new file only containing this very example and refactoring the anonymous function to normal functions?
Sorry for the delay in reviewing, I started reviewing a few weeks ago but never finished my review, thanks for the reminder! |
I applied as much of the comments as I though that would make sense - can this be merged now? |
We never documented AppendInto at the package level. This adds a basic explanation of the function.
Apologies for the delay @baez90. It's been a bit busy recently. |
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.
This looks good, I think my remaining open comments can be addressed in a follow-up.
Thanks for the contribution and your patience @baez90
Follow up to #47 with the following changes. - The tests for AppendInvoke with Close duplicate the tests for AppendInvoke. These can be merged, and the unit tests for Close only need to verify whether the Invoker returned by multierr.Close calls the Close function in the provided io.Closer. - Replace AppendInvoke example with something more realistic. - Update changelog.
Released in v1.7.0. Thanks for the contribution and your patience, @baez90! |
This is meant as a WIP PR for issues #46
For now this shall only showcase the proposed change and allow further discussions on different aspects of the proposed change to ease the overall process.