test: add unit tests for all untested packages (config, logging, client, resume, ftp) #164
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
thwap/pget!164
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/testing-coverage"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Add unit tests for all previously uncovered packages: config, logging, HTTP client, FTP client, resume state. Also fixes a real bug in netrcCreds() where matched credentials were overwritten by subsequent machine entries.
Why
Every package now has test coverage. 7 Kind/Testing issues closed in one PR.
Tests Added
Total: ~48 new tests across 5 new files.
Bugs Fixed
machineentries, matched credentials were overwritten when subsequentmachinelines were processed. Fixed by returning early on match.Testing
go test -race ./...— all pass, no racesgo build ./...,go vet ./...— all cleanBreaking Changes
None
Closes #144, #139, #135, #132, #129, #126, #124
Review: APPROVED
Verification
go test -race ./...— ✅ all pass (config 1.0s, downloader 4.3s, logging 1.0s, progress 1.0s)Changes
internal/config/config_test.go(new, 201 lines) — validate(), parseRate(), applyEnvOverrides() (valid + invalid), loadConfigFile() (normal + missing + comments) — 10 testsinternal/logging/logging_test.go(new, 112 lines) — Print/Printf/Verbosef/Error/Errorf with quiet/verbose combinations — 11 testsinternal/downloader/client_test.go(new, 106 lines) — NewClient, NewRequest (plain + with headers), Do, context — 5 testsinternal/downloader/resume_test.go(new, 231 lines) — Save/Load round-trip, missing file, size mismatch, chunk mismatch, MarkDone, IsDone (nil-safe), VerifyFileSize, Cleanup, corrupted JSON — 13 testsinternal/downloader/ftp_test.go(new, 164 lines) — ParseFTPURL (8 cases), resolveCreds chain (URL priority, netrc fallback, anonymous), netrcCreds (multiple machines, missing file), IsFTPURL — 9 testsinternal/downloader/download_test.go— ParseFTPURL/IsFTPURL moved to ftp_test.go (dedup)internal/downloader/ftp.go— netrcCreds() bug fix +os/user.Current()→os.UserHomeDir()Bug fix: netrcCreds() race condition
machineentries, matched credentials were overwritten by subsequent entriesmachineandpasswordhandlersos/user.Current()toos.UserHomeDir()(simpler, no cgo)Issues closed
Closes #124, #126, #129, #132, #135, #139, #144 on merge.
30cc7083dba98c7c38fbNew commits pushed, approval review dismissed automatically according to repository settings
Re-review: APPROVED
New commit since prior review:
.golangci.yml— cleaned uprunsection ordering; removed test exclusions (errcheck on _test.go, unused archiver/fetcher paths)_(os.Setenv,w.Write,resp.Body.Close)All tests pass with
-race. Still APPROVED.