Add comprehensive test coverage for errext/errorset.go#269
Add comprehensive test coverage for errext/errorset.go#269
Conversation
Co-authored-by: SuperSandro2000 <7258858+SuperSandro2000@users.noreply.github.com>
Co-authored-by: SuperSandro2000 <7258858+SuperSandro2000@users.noreply.github.com>
Co-authored-by: SuperSandro2000 <7258858+SuperSandro2000@users.noreply.github.com>
majewsky
left a comment
There was a problem hiding this comment.
In assert.Equal() calls, the documented argument order is (t, actual, expected), but this changeset uses (t, expected, actual). Please flip the last two arguments in each call, to ensure that arguments are correctly identified in error messages.
Co-authored-by: SuperSandro2000 <7258858+SuperSandro2000@users.noreply.github.com>
Fixed in commit 2095757. All assert.Equal calls now use the correct parameter order (t, actual, expected). |
Co-authored-by: SuperSandro2000 <7258858+SuperSandro2000@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR successfully adds comprehensive test coverage for errext/errorset.go, increasing coverage from 0% to 88%, well exceeding the 70% target. The tests thoroughly exercise all public methods of the ErrorSet type while leaving the original implementation unchanged.
Key Changes:
- Added 10 test functions covering all ErrorSet methods (Add, Addf, Append, IsEmpty, Join, JoinedError, LogFatalIfError)
- Included edge case testing (nil errors, empty sets, various separators)
- Added integration test combining multiple methods
- Verified error wrapping behavior via errors.Is()
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
errext/errorset_test.go
Outdated
| testLogFatalWithEmptyErrorSet(emptyErrs) | ||
| } | ||
|
|
||
| func testLogFatalWithEmptyErrorSet(errs ErrorSet) { |
There was a problem hiding this comment.
TBH, I don't like the naming of this function with the un-exported test.... Could we change that, so it's more clear that this is a test-internal helper function?
There was a problem hiding this comment.
Renamed to helperLogFatalIfErrorWithEmptySet in commit 3eca88b. The function now clearly indicates it's a helper rather than a test function.
There was a problem hiding this comment.
The helper function was already renamed to helperLogFatalIfErrorWithEmptySet in commit 3eca88b as noted in my previous reply. The change is already in place.
Co-authored-by: SuperSandro2000 <7258858+SuperSandro2000@users.noreply.github.com>
Merging this branch will increase overall coverage
Coverage by fileChanged unit test files
|
1 similar comment
Merging this branch will increase overall coverage
Coverage by fileChanged unit test files
|
|
We have learned from this experience, but won't be taking this test suite since the marginal value provided by it is too small compared to the increase of the codebase. |
Summary
Successfully increased test coverage for
errext/errorset.gofrom 0% to 88%, well exceeding the requested 70% minimum.Coverage Results:
Add(): 100%Addf(): 100%Append(): 100%IsEmpty(): 100%Join(): 100%JoinedError(): 100%Error()(joinedError): 100%Unwrap()(joinedError): 100% (tested indirectly via errors.Is())LogFatalIfError(): 50% (cannot fully test os.Exit(1) behavior)All tests pass ✅
Code review feedback addressed ✅
Security scan passed ✅
Original code unchanged ✅
Tests focus on public API rather than implementation details ✅
Helper function naming clarified ✅
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.