Skip to content

Migrate pkg/cli/git_test.go to testify assertions#34775

Merged
pelikhan merged 3 commits into
mainfrom
copilot/testify-expert-improve-test-quality-another-one
May 25, 2026
Merged

Migrate pkg/cli/git_test.go to testify assertions#34775
pelikhan merged 3 commits into
mainfrom
copilot/testify-expert-improve-test-quality-another-one

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 25, 2026

pkg/cli/git_test.go had solid coverage but still relied on raw t.Fatal* / t.Error* checks throughout. This updates the file to use the repository’s standard testify assertion style while preserving the existing Git test scenarios and table-driven structure.

  • Adopt require for setup and execution prerequisites

    • Replaced setup-time t.Fatalf(...) calls with require.NoError(...) for temp dir setup, repo initialization steps, file creation, and command execution that must succeed for the test to remain valid.
  • Adopt assert for behavioral checks

    • Replaced raw t.Error(...) / t.Errorf(...) checks with targeted assert.* calls such as:
      • assert.Equal(...) for branch names, hosts, remote names, and repository slugs
      • assert.Contains(...) for commit log validation
      • assert.Error(...) for expected failure paths
      • assert.True(...) / assert.False(...) / assert.Empty(...) / assert.NotEmpty(...) for status and presence checks
  • Split compound status checks into explicit assertions

    • Workflow file status tests now verify IsModified, IsStaged, and HasUnpushedCommits independently, which makes failures more precise and easier to diagnose.
  • Keep test behavior unchanged

    • No production code changes.
    • No scenario additions or removals.
    • Existing helper flow and subtest structure remain intact.

Example of the assertion style change:

status, err := checkWorkflowFileStatus(workflowFile)
require.NoError(t, err, "get workflow file status for clean file")
assert.False(t, status.IsModified, "clean file should not be marked modified")
assert.False(t, status.IsStaged, "clean file should not be marked staged")
assert.False(t, status.HasUnpushedCommits, "clean file should not report unpushed commits")

Copilot AI and others added 2 commits May 25, 2026 21:41
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot AI changed the title [WIP] Migrate pkg/cli/git_test.go to use testify assertions Migrate pkg/cli/git_test.go to testify assertions May 25, 2026
Copilot AI requested a review from gh-aw-bot May 25, 2026 21:50
@pelikhan pelikhan marked this pull request as ready for review May 25, 2026 21:51
Copilot AI review requested due to automatic review settings May 25, 2026 21:51
@pelikhan pelikhan merged commit 47c4e79 into main May 25, 2026
2 checks passed
@pelikhan pelikhan deleted the copilot/testify-expert-improve-test-quality-another-one branch May 25, 2026 21:52
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 pull request updates pkg/cli/git_test.go to use the repository’s standard testify assertion style (require for prerequisites and assert for behavioral checks) while keeping the existing Git-related test scenarios and structure intact.

Changes:

  • Replaced setup-time t.Fatal*/t.Error* checks with require.NoError where test execution cannot proceed on failure.
  • Replaced behavioral validations with targeted assert.* calls (e.g., Equal, Contains, Error, Empty, True/False).
  • Split compound workflow status checks into explicit assertions for clearer failure output.
Show a summary per file
File Description
pkg/cli/git_test.go Migrates Git unit tests to testify (assert/require) for clearer, more consistent assertions without changing test behavior.

Copilot's findings

Tip

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

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

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/cli/git_test.go — migrate to testify assertions

4 participants