Skip to content

feat(drive): add download command#71

Merged
rianjs merged 1 commit intomainfrom
feat/65-drive-download
Jan 25, 2026
Merged

feat(drive): add download command#71
rianjs merged 1 commit intomainfrom
feat/65-drive-download

Conversation

@rianjs
Copy link
Copy Markdown
Contributor

@rianjs rianjs commented Jan 25, 2026

Summary

  • Add gro drive download <file-id> command for downloading files
  • Regular files download directly; Google Workspace files require --format flag for export
  • Support --output, --format, and --stdout flags
  • Add DownloadFile() and ExportFile() methods to Drive client
  • Add export format mappings for Documents, Spreadsheets, Presentations, Drawings

Export Formats

  • Documents: pdf, docx, txt, html, md, rtf, odt
  • Spreadsheets: pdf, xlsx, csv, tsv, ods
  • Presentations: pdf, pptx, odp
  • Drawings: pdf, png, svg, jpg

Test Plan

  • gro drive download --help shows correct usage
  • Tests for command flags and argument validation
  • Tests for output path determination
  • Tests for export MIME type mapping
  • Tests for file extension helpers
  • make verify passes

Closes #65

Add `gro drive download` command to download files from Google Drive:
- Download regular files directly
- Export Google Workspace files (Docs, Sheets, Slides) to various formats
- Support --output, --format, and --stdout flags
- Add DownloadFile and ExportFile methods to Drive client
- Add export format mappings for all Google Workspace types

Supported export formats:
- Documents: pdf, docx, txt, html, md, rtf, odt
- Spreadsheets: pdf, xlsx, csv, tsv, ods
- Presentations: pdf, pptx, odp
- Drawings: pdf, png, svg, jpg

Closes #65
@rianjs
Copy link
Copy Markdown
Contributor Author

rianjs commented Jan 25, 2026

Test Coverage Assessment for PR #71

Summary

This PR adds a gro drive download command with export functionality for Google Workspace files. The test coverage is adequate for the new code, following established patterns in the codebase.

What's Well Tested

internal/drive/files.go (new functions):

  • GetExportMimeType() - comprehensive tests covering all file types (Document, Spreadsheet, Presentation, Drawing), error cases for unsupported formats, and invalid source types
  • GetSupportedExportFormats() - tested for all workspace file types plus the nil return case
  • GetFileExtension() - all 11 supported formats tested plus unknown format edge case

internal/cmd/drive/download.go:

  • determineOutputPath() - well-tested helper function with 8 test cases covering user-specified paths, format-based extension replacement, and various export formats
  • Command structure tests (flags, arguments, descriptions) - consistent with other commands in the codebase

What's Not Tested (and why it's acceptable)

runDownload() function (lines 52-121):

  • This is the main command runner that orchestrates API calls. It's not unit tested, which is consistent with other commands in this codebase (e.g., list, search, get commands also don't test their run* functions).
  • Testing this function would require mocking the Google Drive API client, which is not done anywhere in the existing codebase.
  • The business logic it uses (IsGoogleWorkspaceFile, GetExportMimeType, determineOutputPath) is tested.

Client.DownloadFile() and Client.ExportFile() (lines 76-103 in client.go):

  • These are thin wrappers around Google's API client. Existing client methods (ListFiles, GetFile) also have no unit tests.
  • Testing these would require extensive mocking of the Google Drive API, which provides limited value for read-only pass-through methods.

Coverage Metrics

Package Coverage
internal/cmd/drive 46.0%
internal/drive 62.4%

These numbers are reasonable given that:

  1. The untested code is primarily API orchestration
  2. Pure functions with business logic are well covered
  3. The pattern matches existing commands in the codebase

Verdict

The test coverage is acceptable. The PR:

  • Tests all pure functions with meaningful logic
  • Tests edge cases and error conditions
  • Follows established testing patterns in the codebase
  • Doesn't introduce untested business logic

No additional tests are required for this PR to merge safely.

@rianjs rianjs merged commit 638fdd3 into main Jan 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(drive): add download command

1 participant