Skip to content

feat(drive): add get command#70

Merged
rianjs merged 1 commit intomainfrom
feat/64-drive-get
Jan 25, 2026
Merged

feat(drive): add get command#70
rianjs merged 1 commit intomainfrom
feat/64-drive-get

Conversation

@rianjs
Copy link
Copy Markdown
Contributor

@rianjs rianjs commented Jan 25, 2026

Summary

  • Add gro drive get <file-id> command to show detailed file metadata
  • Display: ID, name, type, size, created/modified dates, owner, shared status, web link, parent
  • Support --json flag for JSON output
  • Handle Google Docs (no size) gracefully by showing "-"

Test Plan

  • gro drive get --help shows usage
  • Tests for command flags and argument validation
  • Tests for printFileDetails() with various file scenarios
  • make verify passes

Closes #64

Add `gro drive get` command to show detailed file metadata:
- Display ID, name, type, size, created/modified dates
- Show owner, shared status, web link, parent folder
- Support --json flag for JSON output
- Handle Google Docs (no size) gracefully

Closes #64
@rianjs
Copy link
Copy Markdown
Contributor Author

rianjs commented Jan 25, 2026

Test Coverage Assessment for PR #70

Summary

The test coverage for this PR is adequate and follows the established patterns in the codebase. The tests appropriately focus on what can be tested in isolation without mocking the OAuth/API infrastructure.

What's Covered

Command Configuration Tests (TestGetCommand)

  • Command Use string validation
  • Argument validation (requires exactly 1 argument)
  • JSON flag presence and defaults
  • Short description exists

Output Formatting Tests (TestPrintFileDetails)

  • Complete file with all fields populated
  • Size formatting for regular files (shows 1.5 MB)
  • Zero-size handling for Google Docs (shows -)
  • Shared/unshared status display
  • Multiple owners comma-separated
  • Graceful handling of minimal files (no timestamps, no owner, no links)

Analysis

Strengths:

  1. Tests follow the exact same patterns as list_test.go and search_test.go, maintaining consistency
  2. Good edge case coverage in printFileDetails - tests cover Google Docs (size=0), private files, multiple owners, and minimal metadata
  3. The helper functions this command uses (formatSize, GetTypeName, ParseFile) are already tested in list_test.go and files_test.go
  4. The ClientFactory injection pattern in output.go enables mocking if deeper integration tests are added later

What's Not Tested (and why that's acceptable):

  1. runGet execution path - This requires a mock client. The codebase currently doesn't test runList or runSearch either. The DriveClientInterface exists for this purpose, but the test infrastructure to inject mocks isn't used in existing command tests. This is consistent with the codebase approach.
  2. JSON output path - Uses the same printJSON helper tested implicitly elsewhere.
  3. Error handling in runGet - The error wrapping is straightforward (fmt.Errorf("failed to get file %s: %w")).

Verdict

No gaps that a reviewer would flag. The tests:

  • Cover the new business logic (printFileDetails)
  • Validate command configuration
  • Follow established patterns in the codebase
  • Test edge cases appropriately

The untested code paths are infrastructure-level concerns that are consistent with how other drive commands are tested. The GetFile client method itself uses the same pattern as ListFiles which is also not integration-tested.


Reviewed at commit: c351622

@rianjs rianjs merged commit 6c9aa3f 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 get command

1 participant