test(ftp): add unit tests for FTP client #135

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

internal/downloader/ftp.go has no tests. 171 lines of FTP protocol integration code with no coverage.

Should cover:

  • ParseFTPURL — various URL formats, default port, user/password extraction, invalid schemes
  • DialFTP — connection with timeout
  • LoginFTP — anonymous vs explicit credentials
  • GetFTPFileSize — happy path, error wrapping
  • SupportsREST — REST support detection
  • ProbeFTP — full probe flow, size fallback
  • DownloadFTPRange / DownloadFTPSingle — range download construction
  • ftpReadCloser — Read/Close behavior

Consider using a mock FTP server or the github.com/fclairamb/ftpserverlib test utilities.

Discovered during review of PR #133.

`internal/downloader/ftp.go` has no tests. 171 lines of FTP protocol integration code with no coverage. Should cover: - `ParseFTPURL` — various URL formats, default port, user/password extraction, invalid schemes - `DialFTP` — connection with timeout - `LoginFTP` — anonymous vs explicit credentials - `GetFTPFileSize` — happy path, error wrapping - `SupportsREST` — REST support detection - `ProbeFTP` — full probe flow, size fallback - `DownloadFTPRange` / `DownloadFTPSingle` — range download construction - `ftpReadCloser` — Read/Close behavior Consider using a mock FTP server or the `github.com/fclairamb/ftpserverlib` test utilities. Discovered during review of PR #133.
Owner

Closing — handled in PR #164. ftp_test.go covers ParseFTPURL, resolveCreds, netrcCreds, IsFTPURL, and credential resolution chain.

Closing — handled in PR #164. ftp_test.go covers ParseFTPURL, resolveCreds, netrcCreds, IsFTPURL, and credential resolution chain.
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#135
No description provided.