Skip to content

Migrate pkg/repoutil tests to testify assertions#24085

Merged
pelikhan merged 2 commits intomainfrom
copilot/improve-repoutil-test-quality
Apr 2, 2026
Merged

Migrate pkg/repoutil tests to testify assertions#24085
pelikhan merged 2 commits intomainfrom
copilot/improve-repoutil-test-quality

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 2, 2026

pkg/repoutil/repoutil_test.go used only the standard testing package with manual error checks and value comparisons. Migrated to testify for consistent assertion style and clearer failure messages.

Changes

  • Imports: Added testify/assert and testify/require
  • Error assertions: Replaced if err == nil/!= nil { t.Errorf(...) } with require.Error/require.NoError
  • Value assertions: Replaced manual field comparisons with assert.Equal including descriptive messages
  • TestSplitRepoSlug_Whitespace: Added expectedOwner/expectedRepo fields to the test table — previously the function discarded the returned values entirely
  • TestSplitRepoSlug_Idempotent: Refactored bare loop into t.Run subtests with testify assertions

Before:

if err == nil {
    t.Errorf("SplitRepoSlug(%q) expected error, got nil", tt.slug)
}
if owner != tt.expectedOwner {
    t.Errorf("SplitRepoSlug(%q) owner = %q; want %q", tt.slug, owner, tt.expectedOwner)
}

After:

require.Error(t, err, "SplitRepoSlug(%q) should return an error", tt.slug)
// ...
require.NoError(t, err, "SplitRepoSlug(%q) should not return an error", tt.slug)
assert.Equal(t, tt.expectedOwner, owner, "SplitRepoSlug(%q) owner mismatch", tt.slug)

Copilot AI changed the title [WIP] Improve test quality in pkg/repoutil/repoutil_test.go Migrate pkg/repoutil tests to testify assertions Apr 2, 2026
Copilot AI requested a review from pelikhan April 2, 2026 12:11
@pelikhan pelikhan marked this pull request as ready for review April 2, 2026 12:12
Copilot AI review requested due to automatic review settings April 2, 2026 12:12
@pelikhan pelikhan merged commit 48f1f0e into main Apr 2, 2026
52 of 53 checks passed
@pelikhan pelikhan deleted the copilot/improve-repoutil-test-quality branch April 2, 2026 12:12
Copy link
Copy Markdown
Contributor

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 migrates pkg/repoutil unit tests to use testify assertions for more consistent style and clearer failure output.

Changes:

  • Switched from manual if err != nil / t.Errorf checks to require.NoError / require.Error.
  • Replaced manual field comparisons with assert.Equal and improved failure messages.
  • Updated whitespace and idempotency tests to assert returned owner/repo values and to use subtests.

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

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/repoutil/repoutil_test.go

3 participants