Skip to content

test(errorutil): improve edge-case coverage and reduce assertion noise#46366

Merged
pelikhan merged 2 commits into
mainfrom
copilot/testify-expert-improve-test-quality-yet-again
Jul 18, 2026
Merged

test(errorutil): improve edge-case coverage and reduce assertion noise#46366
pelikhan merged 2 commits into
mainfrom
copilot/testify-expert-improve-test-quality-yet-again

Conversation

Copilot AI commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

pkg/errorutil/errors_test.go lacked double-wrapped error cases, boundary inputs for IsNotFoundError, and carried redundant per-assertion failure messages that duplicated t.Run labels. File-level comments were also absent, making the split of responsibility between errors_test.go and spec_test.go implicit.

Changes

errors_test.go

  • New boundary cases for TestIsNotFoundError: exact "404" (no surrounding text) and partial-prefix "404abc" — both should return true and were previously untested.
  • Double-wrapped errors (fmt.Errorf("%w", fmt.Errorf("%w", ...))) added to all three table-driven tests to cover two levels of wrapping, not just one.
  • Removed redundant format strings from all assert.Equal calls — the subtest name is already surfaced by t.Run in failure output.
  • Added file-header scope comment to declare this file owns behavioral edge-case and boundary tests.

spec_test.go

  • Added file-header scope comment to declare this file owns public API contract tests tied to the README.
// Before — redundant
assert.Equal(t, tt.want, got, "IsNotFoundError result mismatch for subtest %s", tt.name)

// After
assert.Equal(t, tt.want, got)

- Add file-header scope comments to errors_test.go and spec_test.go
- Remove redundant failure-message format strings from all three table loops
- Add double-wrapped error cases to TestIsNotFoundError, TestIsForbiddenError, TestIsGoneError
- Add boundary value cases (exact "404", partial "404abc") to TestIsNotFoundError

Closes #46291

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve test quality for errorutil tests test(errorutil): improve edge-case coverage and reduce assertion noise Jul 18, 2026
Copilot AI requested a review from pelikhan July 18, 2026 07:35
@pelikhan
pelikhan marked this pull request as ready for review July 18, 2026 08:09
Copilot AI review requested due to automatic review settings July 18, 2026 08:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Improves errorutil edge-case coverage and clarifies test-file responsibilities.

Changes:

  • Adds boundary and double-wrapped error cases.
  • Removes redundant assertion messages.
  • Documents behavioral versus API-contract test scope.
Show a summary per file
File Description
pkg/errorutil/errors_test.go Expands classifier coverage and simplifies assertions.
pkg/errorutil/spec_test.go Documents responsibility for README-backed contract tests.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Medium

@pelikhan
pelikhan merged commit 65a55ec into main Jul 18, 2026
32 checks passed
@pelikhan
pelikhan deleted the copilot/testify-expert-improve-test-quality-yet-again branch July 18, 2026 08:47
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.82.13

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.

[testify-expert] Improve Test Quality: pkg/errorutil/errors_test.go

3 participants