2.5 KiB
Phase 4 Coverage Notes
Phase 4 added broad unit coverage plus opt-in integration coverage for database-dependent behavior.
Default checks
These run without MySQL or external services:
go test ./...
go vet ./...
go test -cover ./...
Current default coverage snapshot after Phase 4 implementation:
internal/app 62.5%
internal/backup 42.3%
internal/config 79.5%
internal/dbutil 8.6%
internal/gitutil 89.3%
internal/httputil 100.0%
internal/validate 100.0%
cmd/gitocean remains effectively untestable in-process because main() intentionally calls os.Exit; command behavior is covered through internal/app.Run and CLI helper tests instead.
Integration checks
Integration tests are behind the integration build tag and skip unless required environment variables are set:
go test -tags=integration ./...
For MySQL-backed tests:
GITOOCEAN_TEST_MYSQL_DSN='user:pass@tcp(127.0.0.1:3306)/gitocean_test?parseTime=true' go test -tags=integration ./...
The integration tests refuse to run against a database name that does not contain test.
Intentionally environment-dependent areas
The following areas are covered either by opt-in integration tests or by focused wrapper/helper tests rather than exhaustive default unit coverage:
- MySQL database auto-creation (
internal/dbutil.OpenMySQLAndCreateDatabaseIfMissing) - Full migration execution against a real MySQL database
mysqldump,mysql, andtarsubprocess backup/restore executiongit http-backendCGI execution success paths- Full OS process behavior of
cmd/gitocean/main.go
Behavior covered by default tests
Default tests now cover:
- Validators and reserved names
- Client/server config load/save and env overrides
- Strict JSON helpers
- MySQL identifier quoting and duplicate-column detection
- Git utility behavior with temp bare repos
- CLI parsing, dispatch errors, human-readable output, and JSON opt-ins
- Direct server user management parsing and DB operations
- CLI HTTP workflows for auth, repos, PRs, tokens, admin, and storage checks
- API auth handlers, token handlers, admin handlers
- Repository create/get/search/update/delete/fork/collaborator flows
- Permission helpers for public/private/owner/collaborator access
- PR list/view/create/close/comment flows
- Git path/service parsing, CGI response parsing, and Git HTTP permission denials
- PR diff and merge logic using temp Git repositories
- Migration statement execution with sqlmock