feat: add caching infrastructure for Drive metadata#83
Conversation
- Add test-chocolatey.yml: validates Chocolatey packaging on PRs - Add test-winget.yml: validates Winget manifest schema on PRs - Add chocolatey-publish.yml: manual workflow to publish to Chocolatey - Add winget-publish.yml: manual workflow to publish to Winget - Add snap/snapcraft.yaml: Snap package definition - Add snap job to release.yml (disabled, awaiting personal-files approval) - Migrate Homebrew to goreleaser homebrew_casks (cleaner, includes xattr) - Remove manual update-homebrew job from release.yml
Add a caching layer to support fast repeated lookups for Drive API metadata (shared drive lists, etc). This is Phase 1 of shared drive support. New files: - internal/cache/cache.go: TTL-based cache implementation with GetDrives, SetDrives, Clear, and GetStatus methods - internal/cache/cache_test.go: Comprehensive tests for cache package - internal/cmd/config/cache.go: Cache management commands (show, clear, ttl) Modified files: - internal/config/config.go: Add Config struct, LoadConfig, SaveConfig, GetCacheTTL functions for persisting user settings - internal/cmd/config/config.go: Register cache subcommand - internal/cmd/initcmd/init.go: Add cache TTL prompt during setup - README.md: Document cache configuration and commands Features: - Configurable cache TTL (default 24 hours) set during `gro init` - `gro config cache show` - display cache status - `gro config cache clear` - clear all cached data - `gro config cache ttl <hours>` - update cache TTL - Cache stored in ~/.config/google-readonly/cache/ - Automatic expiration based on TTL
7a2ead0 to
f77d74d
Compare
TDD Assessment: Test Coverage for Caching InfrastructureI reviewed the test coverage for the changes introduced in this PR. Here's the assessment: Coverage Summary
What's Well Tested
The cache package has comprehensive tests covering:
Gaps Requiring Tests
These are critical config management functions that should be tested.
The RecommendationNot sufficient for TDD approach. The cache package itself is well-tested, but the supporting infrastructure (config functions, cache commands) lacks adequate coverage. Suggested additions:
These tests would bring the overall coverage to an acceptable level for confident refactoring and maintenance. |
Summary
This PR adds caching infrastructure to support fast repeated lookups for Drive API metadata. This is Phase 1 of shared drive support.
Closes #84
New Features
Cache package (
internal/cache/): TTL-based cache implementationGetDrives()/SetDrives()for storing shared drive listsClear()to remove all cached dataGetStatus()for cache status reportingCache commands (
gro config cache):gro config cache show- display cache status (location, TTL, cached data)gro config cache clear- clear all cached datagro config cache ttl <hours>- update cache TTLConfig persistence (
internal/config/):Configstruct for user settingsLoadConfig()/SaveConfig()for persistenceInit integration: Cache TTL prompt during
gro initsetupFiles Changed
internal/cache/cache.gointernal/cache/cache_test.gointernal/cmd/config/cache.gointernal/config/config.gointernal/cmd/config/config.gointernal/cmd/initcmd/init.goREADME.mdNext Steps
Phase 2 (#85) will add shared drive support that uses this cache for fast name→ID resolution:
gro drive drivescommand to list shared drives--my-driveand--drive <name>flags for list/search/tree commandsTest plan
make test)make lint)gro initprompts for cache TTLgro config cache show/clear/ttlcommands work