docs/dev-notes/TEST_SUITE_AUDIT.md
Original State: 280 tests across 76 test files, each creating isolated database setups Phase 1 Complete: 6 P1 test files refactored with shared DB setup (bd-1rh) Achieved Speedup: P1 tests now run in 0.43 seconds (vs. estimated 10+ minutes before) Remaining Work: P2 and P3 files still use isolated DB setups
These tests only interact with the database and can safely share a single DB setup per suite:
✓ create_test.go (11 tests) → TestCreateSuite DONE (bd-y6d)
TestCreate_*newTestStore() callslabel_test.go (1 suite with 11 subtests) → Already optimal!
✓ dep_test.go (9 tests) → TestDependencySuite DONE (bd-1rh)
TestDep_*newTestStore() calls✓ list_test.go (3 tests) → TestListCommandSuite + TestListQueryCapabilitiesSuite DONE (bd-1rh)
newTestStore() calls✓ comments_test.go (3 tests) → TestCommentsSuite DONE (bd-1rh)
newTestStore() calls✓ stale_test.go (6 tests) → Individual test functions DONE (bd-1rh)
newTestStore() calls✓ ready_test.go (4 tests) → TestReadySuite DONE (bd-1rh)
newTestStore() callsreopen_test.go (1 test) → Leave as-is or merge
main_test.go (18 tests) → TestMainSuite
newTestStore() callsintegrity_test.go (6 tests) → TestIntegritySuite
newTestStore() calls (many helper calls)export_import_test.go (4 tests) → TestExportImportSuite
newTestStore() callsThese have a mix - some can share DB, some need isolation:
Note: Legacy daemon test files (daemon_test.go, daemon_autoimport_test.go, etc.) have been removed as part of the daemon-to-Dolt migration.
Recommendation: Keep server/RPC tests isolated (they already have //go:build integration tags)
Recommendation: Keep git tests isolated (need real git repos)
Tests that already use good patterns:
//go:build integration tag ✓//go:build integration tags ✓//go:build integrationRecommendation: Most can share DB within their suite
Recommendation: Need isolation (modify filesystem)
Recommendation: Can share DB or may not need DB at all
Recommendation: Need isolation (modify DB schema)
Recommendation: Mix - some can share, some need isolation
All P1 files refactored for immediate speedup:
TestCreateSuiteTestDependencySuiteTestCommentsSuiteTestListCommandSuite + TestListQueryCapabilitiesSuiteTestReadySuiteResults: All P1 tests now run in 0.43 seconds (vs. estimated 10+ minutes before)
Pattern to follow: Use label_test.go as the template!
func TestCreateSuite(t *testing.T) {
tmpDir := t.TempDir()
testDB := filepath.Join(tmpDir, ".beads", "beads.db")
s := newTestStore(t, testDB)
ctx := context.Background()
t.Run("BasicIssue", func(t *testing.T) { /* test */ })
t.Run("WithDescription", func(t *testing.T) { /* test */ })
// ... etc
}
After Phase 1 success:
Handle tests that need mixed isolation:
newTestStore() = 280 DB initializations| Suite | Current | Proposed | Speedup |
|---|---|---|---|
| TestCreateSuite | 11 DBs | 1 DB | 10x |
| TestDependencySuite | 4 DBs | 1 DB | 4x |
| TestStaleSuite | 5 DBs | 1 DB | 5x |
| TestIntegritySuite | 15 DBs | 1 DB | 15x |
| TestMainSuite | 14 DBs | 1-2 DBs | 7-14x |
newTestStore() callsnewTestStore()Status: ✓ COMPLETE - All 6 P1 test files refactored Runtime: 0.43 seconds for all P1 tests Speedup: Estimated 10-20x improvement Goal: Under 2 minutes for full test suite after all phases - ON TRACK