This document explains how to run tests for the cherry-picker project.
Run all unit tests:
go test ./...Run tests with coverage:
go test -cover ./...Run tests for a specific package:
go test ./cmd/pick/...
go test ./internal/github/...Integration tests use real git operations in temporary repositories. They are tagged with integration to keep them separate from unit tests.
Run integration tests:
go test -tags=integration ./...Run integration tests for a specific package:
go test -tags=integration ./cmd/pick/...Run integration tests with verbose output:
go test -tags=integration -v ./cmd/pick/...The integration tests in cmd/pick/pick_git_integration_test.go test:
-
Commit Message Manipulation:
moveSignedOffByLinesToEnd()function- Reordering Signed-off-by lines to the end of commit messages
- Handling multiple Signed-off-by lines
- Preserving commit message body
-
Git Operations: Core git helper functions
getCommitInfo()- Retrieving commit informationgetConflictedFiles()- Detecting merge conflictsperformCherryPick()- Cherry-picking commits
-
Real Git Workflows:
- Creating temporary git repositories
- Cherry-picking without conflicts
- Complex commit message scenarios
Integration tests require:
- Git installed and available in PATH
- No network access required (all tests use local repositories)
- Tests automatically disable GPG commit signing
The project includes convenient Makefile targets for running tests:
# Run unit tests only (fast, default)
make test
# Run integration tests only
make test-integration
# Run all tests (unit + integration)
make test-all
# Run unit tests with coverage report
make test-coverage
# Run all tests with coverage report
make test-coverage-all
# Run all checks (fmt, vet, unit tests)
make checkGenerate detailed coverage report:
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.outCurrent coverage status (unit tests only):
-
High Coverage (>60%):
- internal/config: 84.6%
- cmd/config: 84.0%
- cmd/status: 73.4%
- internal/commands: 65.9%
- cmd/retry: 64.9%
- cmd/summary: 64.7%
-
Medium Coverage (30-60%):
- cmd/merge: 57.1%
-
Areas for Improvement (<30%):
- cmd/fetch: 19.9%
- internal/github: 14.7%
- cmd/pick: 13.2%
With integration tests (make test-coverage-all):
- cmd/pick: 13.2% → 37.4% (+24.2%)
Note: Lower coverage in some packages is expected as they contain GitHub API integration code and git command execution that would require network access or extensive mocking.