test(downloader): add unit tests for range request logic #132

Closed
opened 2026-07-13 17:50:26 +00:00 by the.auditor · 1 comment
Owner

internal/downloader/range.go has no tests. The range request logic is core to parallel chunked downloads and should have table-driven tests.

Should cover:

  • ProbeURL — HEAD request handling, Content-Length parsing, Accept-Ranges detection
  • SplitChunks — equal division, last chunk absorbs remainder, edge cases (zero size, negative size, single chunk)
  • BuildRangeHeader — valid Range header format for various chunks
  • Edge cases: missing Content-Length, invalid Content-Length, comma-separated Accept-Ranges

Consider using httptest.NewServer for testing ProbeURL.

Discovered during review of PR #130.

`internal/downloader/range.go` has no tests. The range request logic is core to parallel chunked downloads and should have table-driven tests. Should cover: - `ProbeURL` — HEAD request handling, Content-Length parsing, Accept-Ranges detection - `SplitChunks` — equal division, last chunk absorbs remainder, edge cases (zero size, negative size, single chunk) - `BuildRangeHeader` — valid Range header format for various chunks - Edge cases: missing Content-Length, invalid Content-Length, comma-separated Accept-Ranges Consider using `httptest.NewServer` for testing `ProbeURL`. Discovered during review of PR #130.
Owner

Closing — handled in PR #161. SplitChunks, BuildRangeHeader, and ProbeURL tests in download_test.go.

Closing — handled in PR #161. SplitChunks, BuildRangeHeader, and ProbeURL tests in download_test.go.
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#132
No description provided.