-
Notifications
You must be signed in to change notification settings - Fork 4
Add comprehensive test coverage for errext/errorset.go #269
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
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot please do that
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.
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
|
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.