test: add e2e test suite for CLI binary-level testing#24
Merged
Conversation
|
❌ CI Failed - Lint check failed (Go 1.26) Coverage: unavailable Previous checks passed: Format ✓ Lint ✗ Tests ✗ |
There was a problem hiding this comment.
Pull request overview
Adds a new Go e2e test suite under internal/e2e/ that builds the gitm binary once and exercises CLI commands end-to-end using real temporary git repositories and isolated HOME directories (separate DB per test).
Changes:
- Introduces an e2e harness (
TestMain, env isolation, git helpers, assertion helpers) to run the compiledgitmbinary. - Adds command-level e2e coverage for repo/status/branch/checkout/update plus limited coverage for TUI-heavy commands and help/version/upgrade.
- Documents several observed behavioral “findings” via logs in tests.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 23 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/e2e/helpers_test.go | Builds gitm once and provides isolated env + git/assert helpers for the e2e suite. |
| internal/e2e/repo_test.go | E2E coverage for gitm repo add/list/remove/rename (incl. auto-detect). |
| internal/e2e/status_test.go | E2E coverage for gitm status across common repo states and --fetch. |
| internal/e2e/branch_test.go | E2E coverage for gitm branch create/rename across --repo/--all/--from/--no-remote. |
| internal/e2e/checkout_test.go | E2E coverage for gitm checkout scenarios (dirty, untracked-only, remote-only, pull-after-switch). |
| internal/e2e/update_test.go | E2E coverage for gitm update scenarios (up-to-date, remote-ahead, dirty, diverged). |
| internal/e2e/track_test.go | Edge-case coverage for gitm track/untrack in non-interactive contexts. |
| internal/e2e/interactive_test.go | Edge-case coverage/logging for TUI-heavy commands (commit/discard/stash/reset). |
| internal/e2e/help_test.go | E2E coverage for --help/--version, unknown command behavior, and upgrade smoke check. |
|
✅ All checks passed (Go 1.26) Coverage: 67.5% |
Adds 77 automated e2e tests that build the gitm binary and exercise it as a real user would, using isolated HOME directories and real git repos. Covers: repo add/list/remove/rename, status, branch create/rename, checkout, update, track/untrack, commit, discard, stash, reset, upgrade, help/version. Key findings documented in test output via t.Log: - checkout fails for unfetched remote-only branches - status DIRTY column counts untracked files as 'modified' - duplicate alias on repo add silently ignored
- Check os.MkdirAll return values (errcheck) - Remove unused gitLog and isDirty helper methods (unused) - Use errors.As instead of type assertion on *exec.ExitError (errorlint) - Add missing errors import
- Cross-platform: replace /dev/null with os.DevNull, add Windows HOME env vars (USERPROFILE/HOMEDRIVE/HOMEPATH), clean up TestMain temp dir - Stronger assertions: replace t.Log-only tests with real assertions for remote-only checkout, diverged update, dirty branch create, non-existent branch rename, and stash list empty state - Broader match fixes: 'No' -> specific messages like 'No dirty repositories found', 'No untracked files found' - Skip TUI-dependent tests that cannot run in non-TTY environments (commit protection, reset, track file picker) - Remove custom contains/findSubstring reimplementing strings.Contains - Use filepath.Join instead of string concatenation with '/' - Remove unused dataDir struct field - Use upgrade --help instead of real network call in TestUpgrade
6553b89 to
c124367
Compare
|
✅ All checks passed (Go 1.26) Coverage: 68.1% |
- Use filepath.Join for non-existent path test (cross-platform) - Assert exit codes in AutoDetectWithDepth, remove _ = r1/r2 workaround - Replace generic "1" with "changed" in DirtyModified check - Use specific "No files matching" assertion in untrack test - Assert deterministic non-zero exit for unknown --repo alias - Assert idempotent behavior for duplicate path add (exit 0 + warning) - Assert non-zero exit for conflicting alias (fixed in PR #25)
|
✅ All checks passed (Go 1.26) Coverage: 68.1% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
t.TempDir()(no mocks, per AGENTS.md)Test Coverage
repo add/list/remove/renamestatusbranch create/renamecheckoutupdatetrack/untrackcommit/discardstashhelp/version/upgradeKey Findings (documented via t.Log in tests)
ls-remoteconfirms existence but nogit fetchruns beforegit checkout--aliassilently ignored (exit 0, no error message)How to run
go test ./internal/e2e/ -v -race -timeout 120s