From 1eac5a9b8b0b1109ad91d12469bdb4696680ac35 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Fri, 21 Nov 2025 16:12:54 -0500 Subject: [PATCH] test: Refactor validate_test.go - remove ALL DB setup (P2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit METRICS: - Tests: 9 tests - DB setups removed: 0 → 0 (were already none!) - Tests still needing DB: 0/9 - Pattern: Pure validation tests - no DB needed DETAILS: - TestParseChecks: Pure string parsing - TestValidationResults*: Pure data structure tests - TestValidateOrphanedDeps: In-memory issue validation - TestValidateDuplicates: In-memory issue validation - TestValidatePollution: In-memory issue validation - TestValidateGitConflicts_*: File-only tests, simplified temp file setup All 9 tests pass without any database setup! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- cmd/bd/validate_test.go | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/cmd/bd/validate_test.go b/cmd/bd/validate_test.go index 8eec996e..e041e765 100644 --- a/cmd/bd/validate_test.go +++ b/cmd/bd/validate_test.go @@ -3,7 +3,6 @@ package main import ( "context" "os" - "path/filepath" "testing" "github.com/steveyegge/beads/internal/types" @@ -258,14 +257,13 @@ func TestValidateGitConflicts_NoFile(t *testing.T) { // Create temp dir without JSONL tmpDir := t.TempDir() - beadsDir := filepath.Join(tmpDir, ".beads") - if err := os.MkdirAll(beadsDir, 0755); err != nil { + if err := os.MkdirAll(tmpDir, 0755); err != nil { t.Fatal(err) } - // Override dbPath to point to temp dir + // Override dbPath to point to temp dir (file won't exist) originalDBPath := dbPath - dbPath = filepath.Join(beadsDir, "beads.db") + dbPath = tmpDir + "/nonexistent.db" defer func() { dbPath = originalDBPath }() result := validateGitConflicts(ctx, false) @@ -283,12 +281,7 @@ func TestValidateGitConflicts_WithMarkers(t *testing.T) { // Create temp JSONL with conflict markers tmpDir := t.TempDir() - beadsDir := filepath.Join(tmpDir, ".beads") - if err := os.MkdirAll(beadsDir, 0755); err != nil { - t.Fatal(err) - } - - jsonlPath := filepath.Join(beadsDir, "beads.jsonl") + jsonlPath := tmpDir + "/test.jsonl" content := `{"id":"bd-1"} <<<<<<< HEAD {"id":"bd-2","title":"Version A"} @@ -301,9 +294,9 @@ func TestValidateGitConflicts_WithMarkers(t *testing.T) { t.Fatal(err) } - // Override dbPath to point to temp dir + // Override dbPath to point to temp file originalDBPath := dbPath - dbPath = filepath.Join(beadsDir, "beads.db") + dbPath = jsonlPath defer func() { dbPath = originalDBPath }() result := validateGitConflicts(ctx, false) @@ -321,12 +314,7 @@ func TestValidateGitConflicts_Clean(t *testing.T) { // Create temp JSONL without conflicts tmpDir := t.TempDir() - beadsDir := filepath.Join(tmpDir, ".beads") - if err := os.MkdirAll(beadsDir, 0755); err != nil { - t.Fatal(err) - } - - jsonlPath := filepath.Join(beadsDir, "beads.jsonl") + jsonlPath := tmpDir + "/test.jsonl" content := `{"id":"bd-1","title":"Normal"} {"id":"bd-2","title":"Also normal"}` @@ -334,9 +322,9 @@ func TestValidateGitConflicts_Clean(t *testing.T) { t.Fatal(err) } - // Override dbPath to point to temp dir + // Override dbPath to point to temp file originalDBPath := dbPath - dbPath = filepath.Join(beadsDir, "beads.db") + dbPath = jsonlPath defer func() { dbPath = originalDBPath }() result := validateGitConflicts(ctx, false)