|
| 1 | +# Issue #487 Remaining Work |
| 2 | + |
| 3 | +This document outlines the remaining work for Issue #487 after the quick wins have been addressed. |
| 4 | + |
| 5 | +## ✅ Completed (Quick Wins) |
| 6 | + |
| 7 | +1. **Fixed mutable default args** in `search_notes()` MCP tool |
| 8 | +2. **Fixed Pydantic defaults** in `WatchServiceState` classes |
| 9 | +3. **Fixed list mutation during iteration** in `WatchService.handle_changes()` |
| 10 | +4. **Added regression tests** for all three bugs |
| 11 | + |
| 12 | +## 🔄 Remaining Work |
| 13 | + |
| 14 | +### 1. Coverage Baseline and Restoration |
| 15 | + |
| 16 | +**Goal**: Restore test coverage to ~100% (practical: minimal, justified excludes) |
| 17 | + |
| 18 | +**Tasks**: |
| 19 | +- [ ] Run `just coverage` to establish current baseline |
| 20 | +- [ ] Identify files/functions with missing coverage |
| 21 | +- [ ] Add tests for uncovered code paths |
| 22 | +- [ ] Document any justified coverage excludes (e.g., CLI entry points, debug code) |
| 23 | + |
| 24 | +**Priority**: High - This is the main goal of the issue |
| 25 | + |
| 26 | +### 2. Reduce Mock Usage |
| 27 | + |
| 28 | +**Goal**: Replace mocks with integration tests where practical |
| 29 | + |
| 30 | +**Tasks**: |
| 31 | +- [ ] **High-value targets** (most mocked files): |
| 32 | + - `tests/test_rclone_commands.py` (56 mocks) - Consider using real rclone or temp dirs |
| 33 | + - `tests/sync/test_sync_service.py` (11 mocks) - Many can use real filesystem |
| 34 | + - `tests/services/test_search_service.py` (8 mocks) - Already mostly integration-style |
| 35 | + |
| 36 | +- [ ] **Cloud/external service mocks**: |
| 37 | + - `tests/cli/test_cloud_authentication.py` - Consider mock OAuth server or test fixtures |
| 38 | + - `tests/cli/test_upload.py` - Consider using MinIO (local S3-compatible storage) |
| 39 | + - `tests/test_telemetry.py` - Mock external telemetry endpoint is acceptable |
| 40 | + |
| 41 | +- [ ] **Move appropriate tests to `test-int/`**: |
| 42 | + - Tests that use real DB + real filesystem + real in-process API client belong in `test-int/` |
| 43 | + - Keep unit tests in `tests/` for isolated component testing |
| 44 | + |
| 45 | +**Priority**: Medium - Important for test reliability but not critical |
| 46 | + |
| 47 | +### 3. Architecture/Quality Follow-ups |
| 48 | + |
| 49 | +**Tasks**: |
| 50 | +- [ ] **Cloud-mode DB initialization**: Ensure cloud mode runs required DB init/migrations reliably |
| 51 | + - Even if project reconciliation is skipped |
| 52 | + - Add integration test for cloud mode startup |
| 53 | + |
| 54 | +- [ ] **Telemetry credential optics**: Review client secret in repo |
| 55 | + - Currently marked as "write-only" but still in version control |
| 56 | + - Consider environment variable or config file approach |
| 57 | + - Document security model if keeping in repo |
| 58 | + |
| 59 | +**Priority**: Medium - Quality improvements, not bugs |
| 60 | + |
| 61 | +### 4. Documentation |
| 62 | + |
| 63 | +**Tasks**: |
| 64 | +- [ ] Document coverage expectations in CLAUDE.md or CONTRIBUTING.md |
| 65 | +- [ ] Document when to use mocks vs integration tests |
| 66 | +- [ ] Add examples of good integration tests to test guidelines |
| 67 | + |
| 68 | +**Priority**: Low - Nice to have |
| 69 | + |
| 70 | +## Testing Strategy |
| 71 | + |
| 72 | +### Unit Tests (`tests/`) |
| 73 | +- **Use when**: Testing isolated components with clear boundaries |
| 74 | +- **Mock**: External services, network calls, filesystem (when appropriate) |
| 75 | +- **Examples**: Schema validation, utility functions, parsers |
| 76 | + |
| 77 | +### Integration Tests (`test-int/`) |
| 78 | +- **Use when**: Testing user flows, API endpoints, sync operations |
| 79 | +- **Real components**: Database (SQLite/Postgres), filesystem (tmp_path), in-process API client |
| 80 | +- **Examples**: MCP tool workflows, sync operations, search functionality |
| 81 | + |
| 82 | +### Coverage Goals |
| 83 | +- **Target**: ~100% practical coverage |
| 84 | +- **Acceptable excludes**: CLI entry points, debug code, unreachable error paths |
| 85 | +- **Document**: All coverage excludes with justification |
| 86 | + |
| 87 | +## Next Steps |
| 88 | + |
| 89 | +1. **Run coverage baseline**: `just coverage` (requires approval) |
| 90 | +2. **Triage uncovered code**: Identify what needs tests vs what can be excluded |
| 91 | +3. **Prioritize high-value tests**: Focus on user-facing functionality first |
| 92 | +4. **Reduce strategic mocks**: Start with `test_rclone_commands.py` |
| 93 | +5. **Document patterns**: Add testing guidelines to help future contributions |
| 94 | + |
| 95 | +## References |
| 96 | + |
| 97 | +- Issue: #487 |
| 98 | +- Quick wins commits: [cdc28ee](https://github.com/basicmachines-co/basic-memory/commit/cdc28ee), [bb364dc](https://github.com/basicmachines-co/basic-memory/commit/bb364dc) |
| 99 | +- Test structure: `tests/` (unit), `test-int/` (integration) |
| 100 | +- Coverage tool: `just coverage` → `coverage/index.html` |
0 commit comments