3.1 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			3.1 KiB
		
	
	
	
	
	
	
	
TDD Testing Philosophy - Added to LLMemory
What Was Updated
1. Updated IMPLEMENTATION_PLAN.md
- ✅ Rewrote testing strategy section with integration-first philosophy
 - ✅ Added TDD workflow to Steps 1.3 (Store) and 1.4 (Search)
 - ✅ Each step now has "write test first" as explicit requirement
 - ✅ Test code examples included before implementation examples
 
2. Updated AGENTS.md
- ⚠️ File doesn't exist in opencode root, skipped
 - Created TESTING.md instead with full testing guide
 
3. Created docs/TESTING.md
- ✅ Comprehensive testing philosophy document
 - ✅ TDD workflow with detailed examples
 - ✅ Integration-first approach explained
 - ✅ When to write unit tests (rarely!)
 - ✅ Realistic data seeding strategies
 - ✅ Watch-driven development workflow
 - ✅ Good vs bad test examples
 
4. Created test/integration.test.js
- ✅ Test structure scaffolded with 
.todo()markers - ✅ Shows TDD structure before implementation
 - ✅ Database layer tests
 - ✅ Store command tests
 - ✅ Search command tests
 - ✅ Performance tests
 - ✅ Edge case tests
 
5. Simplified Dependencies
- ⚠️ Removed 
better-sqlite3temporarily (build issues on NixOS) - ✅ Installed: commander, chalk, date-fns, vitest
 - ✅ Tests run successfully (all 
.todo()so pass by default) 
Current Status
Tests Setup: ✅ Complete
npm test          # Runs all tests (currently 0 real tests, 30+ .todo())
npm run test:watch  # Watch mode for TDD workflow
Next Steps (TDD Approach):
- 
Install better-sqlite3 (need native build tools)
# On NixOS, may need: nix-shell -p gcc gnumake python3 npm install better-sqlite3 - 
Write First Real Test (database schema)
test('creates memories table with correct schema', () => { const db = new Database(':memory:'); initSchema(db); const tables = db.prepare("SELECT name FROM sqlite_master WHERE type='table'").all(); expect(tables.map(t => t.name)).toContain('memories'); }); - 
Watch Test Fail (
npm run test:watch) - 
Implement (src/db/schema.js)
 - 
Watch Test Pass
 - 
Move to Next Test
 
TDD Philosophy Summary
DO:
- ✅ Write integration tests first
 - ✅ Use realistic data (50-100 memories)
 - ✅ Test with 
:memory:or temp file database - ✅ Run in watch mode
 - ✅ See test fail → implement → see test pass
 
DON'T:
- ❌ Write unit tests for simple functions
 - ❌ Test implementation details
 - ❌ Use toy data (1-2 memories)
 - ❌ Mock the database (test the real thing)
 
Build Issue Note
better-sqlite3 requires native compilation. On NixOS:
# Option 1: Use nix-shell
nix-shell -p gcc gnumake python3
npm install better-sqlite3
# Option 2: Use in-memory mock for testing
# Implement with native SQLite later
This is documented in test/integration.test.js comments.
Next Session Reminder
Start with: /home/nate/nixos/shared/linked-dotfiles/opencode/llmemory/
- Fix better-sqlite3 installation
 - Remove 
.todo()from first test - Watch it fail
 - Implement schema.js
 - Watch it pass
 - Continue with TDD approach
 
All tests are scaffolded and ready!