Skip to content

feat(drive): add search command#69

Merged
rianjs merged 1 commit intomainfrom
feat/63-drive-search
Jan 25, 2026
Merged

feat(drive): add search command#69
rianjs merged 1 commit intomainfrom
feat/63-drive-search

Conversation

@rianjs
Copy link
Copy Markdown
Contributor

@rianjs rianjs commented Jan 25, 2026

Summary

  • Add gro drive search command for searching files in Google Drive
  • Support full-text content search and filename-only search (--name)
  • Filter by type, owner, modified date range, and folder scope
  • Support --max and --json flags
  • Reuse getMimeTypeFilter() and printFileTable() from list command

Test Plan

  • gro drive search --help shows usage
  • Tests for query building with all filter combinations
  • Tests for query string escaping
  • make verify passes

Closes #63

Add `gro drive search` command to search files in Google Drive:
- Full-text content search
- Filename-only search with --name flag
- Filter by type, owner, modified date
- Search within specific folder with --in-folder
- Support --max and --json flags

Closes #63
@rianjs
Copy link
Copy Markdown
Contributor Author

rianjs commented Jan 25, 2026

Test Coverage Assessment for PR #69

Summary

This PR adds the gro drive search command with comprehensive unit tests for the core business logic. The test coverage is adequate for this type of change.

What's Well-Tested

Command structure (TestSearchCommand):

  • Command Use and Short fields
  • Argument validation (0 or 1 args)
  • All 8 flags verified (max, name, type, owner, modified-after, modified-before, in-folder, json)

Query building (TestBuildSearchQuery):

  • Full-text search vs. name-only search
  • All filter types: type, owner, modified-after, modified-before, in-folder
  • Combined filters
  • Error case for invalid file type
  • Empty query with filters

Query escaping (TestEscapeQueryString):

  • Single quote escaping
  • Empty strings
  • Multiple quotes

Coverage Gaps (Acceptable)

The runSearch function is not directly tested (0% coverage), which follows the existing pattern in this codebase. This function:

  1. Creates the Drive client (tested at integration level)
  2. Calls buildSearchQuery (100% tested)
  3. Calls client.ListFiles (API layer, tested elsewhere)
  4. Handles output with printFileTable and printJSON (shared utilities)

The codebase provides a ClientFactory hook for mocking but no existing tests use it - this is a pre-existing gap, not introduced by this PR.

Edge Cases Covered

  • Query with special characters (single quotes)
  • Empty query string
  • All filter combinations
  • Invalid file type error propagation

Verdict

Approve - The tests cover the critical business logic (buildSearchQuery, escapeQueryString) which is where bugs are most likely to occur. The untested runSearch function is thin glue code that follows an established pattern in the codebase. The test coverage is pragmatic and appropriate.

@rianjs rianjs merged commit 1f70fe6 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 search command

1 participant