Skip to content

Conversation

Copy link

Copilot AI commented Nov 6, 2025

  • Analyze current test coverage for errorset.go (was 0%)
  • Create comprehensive tests for ErrorSet methods
    • Test Add() method with nil and non-nil errors
    • Test Addf() method with formatted error messages
    • Test Append() method to merge ErrorSets
    • Test IsEmpty() method
    • Test Join() method with various separators
    • Test JoinedError() method and its Error() implementation
    • Test Unwrap() method indirectly through errors.Is()
    • Test LogFatalIfError() method (empty ErrorSet case)
  • Run tests to verify coverage reaches 88% (exceeds 70% requirement)
  • Verify no changes to original code
  • Fix formatting issues
  • Correct assert.Equal parameter order to (t, actual, expected) per review
  • Refactor tests to avoid testing implementation details (Unwrap interface)
  • Rename helper function to clarify it's not a test function

Summary

Successfully increased test coverage for errext/errorset.go from 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

This section details on the original issue you should resolve

<issue_title>Increase test coverage [copilot playground]</issue_title>
<issue_description>We want to increase the test coverage of https://github.com/sapcc/go-bits/blob/master/errext/errorset.go to a reasonable amount of at least ~70% . 100% is not necessary and the original code should not be changed.

@copilot can you do that?</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits November 6, 2025 13:58
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>
Copilot AI changed the title [WIP] Increase test coverage for errorset.go Add comprehensive test coverage for errext/errorset.go Nov 6, 2025
Copilot AI requested a review from SuperSandro2000 November 6, 2025 14:09
Copilot finished work on behalf of SuperSandro2000 November 6, 2025 14:09
Copy link
Contributor

@majewsky majewsky left a 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.

@SuperSandro2000
Copy link
Member

@copilot Can you please do @majewsky review? He is really nice and knowledgeable and generally gives very good feedback.

Co-authored-by: SuperSandro2000 <7258858+SuperSandro2000@users.noreply.github.com>
Copy link
Author

Copilot AI commented Nov 6, 2025

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 ar...

Fixed in commit 2095757. All assert.Equal calls now use the correct parameter order (t, actual, expected).

Copilot finished work on behalf of SuperSandro2000 November 6, 2025 15:02
Co-authored-by: SuperSandro2000 <7258858+SuperSandro2000@users.noreply.github.com>
Copy link

Copilot AI left a 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.

testLogFatalWithEmptyErrorSet(emptyErrs)
}

func testLogFatalWithEmptyErrorSet(errs ErrorSet) {
Copy link
Contributor

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot please follow @wagnerd3 suggestion to his full satisfaction

Copy link
Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot please do that

Copy link
Author

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>
Copilot finished work on behalf of SuperSandro2000 November 14, 2025 16:17
@github-actions
Copy link

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/sapcc/go-bits/errext 88.00% (+68.00%) 🌟

Coverage by file

Changed unit test files

  • github.com/sapcc/go-bits/errext/errorset_test.go

1 similar comment
@github-actions
Copy link

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/sapcc/go-bits/errext 88.00% (+68.00%) 🌟

Coverage by file

Changed unit test files

  • github.com/sapcc/go-bits/errext/errorset_test.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Increase test coverage [copilot playground]

4 participants