test(resume): add unit tests for resume state management #144

Closed
opened 2026-07-13 18:16:05 +00:00 by the.auditor · 1 comment
Owner

internal/downloader/resume.go has no tests. 112 lines of serialization/deserialization, file I/O, and thread-safe state management with zero coverage.

Should cover:

  • SaveResumeState — writes valid JSON to .pget file
  • LoadResumeState — loads valid state, handles missing file, corrupted JSON, size mismatch, chunk count mismatch
  • IsDone — returns correct status for completed/incomplete chunks
  • MarkDone — marks chunk, thread safety
  • VerifyFileSize — exact match, mismatch, stat error
  • CleanupResumeState — removes file
  • metaPath — correct path generation
  • Round-trip: save → load → verify all chunks marked as done
  • Integration with Download(): state saved after each chunk, cleaned up on success, preserved on failure

Discovered during review of PR #142.

`internal/downloader/resume.go` has no tests. 112 lines of serialization/deserialization, file I/O, and thread-safe state management with zero coverage. Should cover: - `SaveResumeState` — writes valid JSON to `.pget` file - `LoadResumeState` — loads valid state, handles missing file, corrupted JSON, size mismatch, chunk count mismatch - `IsDone` — returns correct status for completed/incomplete chunks - `MarkDone` — marks chunk, thread safety - `VerifyFileSize` — exact match, mismatch, stat error - `CleanupResumeState` — removes file - `metaPath` — correct path generation - Round-trip: save → load → verify all chunks marked as done - Integration with `Download()`: state saved after each chunk, cleaned up on success, preserved on failure Discovered during review of PR #142.
Owner

Closing — implemented in PR #164. Tests added for config, logging, HTTP client, FTP client, and resume state management.

Closing — implemented in PR #[164](https://git.lan.thwap.org/thwap/pget/pulls/164). Tests added for config, logging, HTTP client, FTP client, and resume state management.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/pget#144
No description provided.