Skip to content

feat: add Google Shared Drive support#87

Merged
rianjs merged 2 commits intomainfrom
feat/85-shared-drive-support
Jan 27, 2026
Merged

feat: add Google Shared Drive support#87
rianjs merged 2 commits intomainfrom
feat/85-shared-drive-support

Conversation

@rianjs
Copy link
Contributor

@rianjs rianjs commented Jan 27, 2026

Summary

Add support for Google Shared Drives (formerly Team Drives) with ergonomic defaults.

  • New gro drive drives command to list accessible shared drives
  • Search now includes all drives by default (My Drive + shared drives)
  • --my-drive flag limits operations to personal drive
  • --drive <name-or-id> targets specific shared drive
  • Case-insensitive drive name resolution with local caching

Changes

New Command

  • gro drive drives - List shared drives (with --refresh, --json flags)

Updated Commands

  • gro drive search - Add --my-drive, --drive flags
  • gro drive list - Add --my-drive, --drive flags
  • gro drive tree - Add --my-drive, --drive flags

API Changes

  • ListFilesWithScope() - New method with corpora/driveId support
  • ListSharedDrives() - New method to fetch shared drives
  • GetFile(), DownloadFile() - Updated with SupportsAllDrives
  • SharedDrive, DriveScope - New types

Test Updates

  • New drives_test.go with command and helper tests
  • Updated mock client with new interface methods
  • Added shared drive fixtures

Test plan

  • make build passes
  • make test passes
  • make lint passes
  • New commands have tests
  • README updated with documentation

Closes #85

Add support for Google Shared Drives (formerly Team Drives) with ergonomic defaults:

- New `gro drive drives` command to list accessible shared drives
- Search now includes all drives by default (My Drive + shared drives)
- New `--my-drive` flag to limit operations to personal drive
- New `--drive <name-or-id>` flag to target specific shared drive
- Case-insensitive drive name resolution with local caching
- Updated `list`, `search`, and `tree` commands with shared drive flags

API integration:
- Add ListFilesWithScope() with corpora/driveId support
- Add ListSharedDrives() to fetch shared drives
- Update GetFile() and DownloadFile() with SupportsAllDrives
- Add DriveScope type for flexible scope configuration

Closes #85
@rianjs
Copy link
Contributor Author

rianjs commented Jan 27, 2026

Test Coverage Assessment for PR #87

I reviewed the changes in this PR and assessed test coverage. Here's my analysis:

What's Well-Tested

Cache Package (internal/cache/) - Excellent coverage

  • New() with default/custom TTL
  • GetDrives() / SetDrives() round-trip
  • Cache expiration logic (stale vs valid)
  • Corrupted JSON handling
  • Clear() and GetStatus() methods

Drives Command (internal/cmd/drive/drives_test.go) - Good coverage

  • Command structure (Use, Args, flags)
  • looksLikeDriveID() helper with comprehensive table-driven tests

Mock Infrastructure - Updated appropriately

  • MockDriveClient updated with ListFilesWithScopeFunc and ListSharedDrivesFunc
  • mockDriveClient in tree_test.go updated to implement new interface methods
  • New fixture helpers for shared drives added

Coverage Gaps to Consider

1. resolveDriveScope() function (drives.go:246-298) - No tests
This function has multiple code paths:

  • --my-drive flag path
  • No --drive flag (all drives) path
  • Drive ID detection (starts with "0A")
  • Name-to-ID resolution via cache
  • Cache miss → API fetch → cache update
  • Drive not found error

This is a critical path that resolves user input to API parameters.

2. buildListQueryWithScope() function (list.go:118-139) - No tests
The existing buildListQuery() has tests, but the new scope-aware version doesn't. The new function has different query building logic for shared drives (no 'root' in parents).

3. resolveDriveScopeForList() function (list.go:142-151) - No tests
Has special handling when a folder ID is provided.

4. buildTreeWithScope() function (tree.go:99-118) - Partial coverage
The existing tree tests use the mock, but don't specifically test the rootName override behavior for shared drives (the else if rootName != "" && depth == 2 branch).

5. Mutually exclusive flag validation - No direct tests
The --my-drive and --drive mutual exclusivity check is added to list, search, and tree commands but isn't tested. Example: calling with both flags should return an error.

6. ListFilesWithScope() API method (client.go:68-105) - No unit tests
This is the new core API method. It handles:

  • Setting Corpora("drive") with DriveId()
  • Setting Corpora("user") for My Drive
  • Setting Corpora("allDrives") for all drives
  • Query and pagination parameters

7. ListSharedDrives() API method (client.go:147-183) - No unit tests
Handles pagination for fetching all shared drives.

Assessment

The PR adds solid infrastructure (cache, mocks, fixtures) and tests the new drives command basics. However, the business logic for scope resolution (resolveDriveScope, buildListQueryWithScope, resolveDriveScopeForList) lacks unit tests. These functions convert user-facing flags into API parameters and are critical paths.

Recommendation: Consider adding tests for:

  1. resolveDriveScope() - at minimum, test the happy paths (my-drive flag, drive flag with ID, drive flag with name)
  2. buildListQueryWithScope() - test query differences for shared drive vs My Drive
  3. Mutual exclusivity validation in at least one command

The API client methods (ListFilesWithScope, ListSharedDrives) are harder to unit test without mocking the Google API, which may be acceptable given the existing testing patterns in this codebase.


Note: This assessment focused on critical business logic paths. The infrastructure changes and command wiring look solid.

Add comprehensive tests for:
- resolveDriveScope() function covering all code paths
- Mutual exclusivity validation for --my-drive and --drive flags
- Case-insensitive drive name matching
- Drive name-to-ID resolution via API

Addresses TDD assessment feedback for PR #87.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@rianjs rianjs merged commit 66c94b0 into main Jan 27, 2026
2 checks passed
@rianjs rianjs deleted the feat/85-shared-drive-support branch January 27, 2026 11:37
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: add Google Shared Drive support

1 participant