test: Refactor validate_test.go - remove ALL DB setup (P2)

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 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-11-21 16:12:54 -05:00
parent 672377544b
commit 1eac5a9b8b

View File

@@ -3,7 +3,6 @@ package main
import ( import (
"context" "context"
"os" "os"
"path/filepath"
"testing" "testing"
"github.com/steveyegge/beads/internal/types" "github.com/steveyegge/beads/internal/types"
@@ -258,14 +257,13 @@ func TestValidateGitConflicts_NoFile(t *testing.T) {
// Create temp dir without JSONL // Create temp dir without JSONL
tmpDir := t.TempDir() tmpDir := t.TempDir()
beadsDir := filepath.Join(tmpDir, ".beads") if err := os.MkdirAll(tmpDir, 0755); err != nil {
if err := os.MkdirAll(beadsDir, 0755); err != nil {
t.Fatal(err) t.Fatal(err)
} }
// Override dbPath to point to temp dir // Override dbPath to point to temp dir (file won't exist)
originalDBPath := dbPath originalDBPath := dbPath
dbPath = filepath.Join(beadsDir, "beads.db") dbPath = tmpDir + "/nonexistent.db"
defer func() { dbPath = originalDBPath }() defer func() { dbPath = originalDBPath }()
result := validateGitConflicts(ctx, false) result := validateGitConflicts(ctx, false)
@@ -283,12 +281,7 @@ func TestValidateGitConflicts_WithMarkers(t *testing.T) {
// Create temp JSONL with conflict markers // Create temp JSONL with conflict markers
tmpDir := t.TempDir() tmpDir := t.TempDir()
beadsDir := filepath.Join(tmpDir, ".beads") jsonlPath := tmpDir + "/test.jsonl"
if err := os.MkdirAll(beadsDir, 0755); err != nil {
t.Fatal(err)
}
jsonlPath := filepath.Join(beadsDir, "beads.jsonl")
content := `{"id":"bd-1"} content := `{"id":"bd-1"}
<<<<<<< HEAD <<<<<<< HEAD
{"id":"bd-2","title":"Version A"} {"id":"bd-2","title":"Version A"}
@@ -301,9 +294,9 @@ func TestValidateGitConflicts_WithMarkers(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
// Override dbPath to point to temp dir // Override dbPath to point to temp file
originalDBPath := dbPath originalDBPath := dbPath
dbPath = filepath.Join(beadsDir, "beads.db") dbPath = jsonlPath
defer func() { dbPath = originalDBPath }() defer func() { dbPath = originalDBPath }()
result := validateGitConflicts(ctx, false) result := validateGitConflicts(ctx, false)
@@ -321,12 +314,7 @@ func TestValidateGitConflicts_Clean(t *testing.T) {
// Create temp JSONL without conflicts // Create temp JSONL without conflicts
tmpDir := t.TempDir() tmpDir := t.TempDir()
beadsDir := filepath.Join(tmpDir, ".beads") jsonlPath := tmpDir + "/test.jsonl"
if err := os.MkdirAll(beadsDir, 0755); err != nil {
t.Fatal(err)
}
jsonlPath := filepath.Join(beadsDir, "beads.jsonl")
content := `{"id":"bd-1","title":"Normal"} content := `{"id":"bd-1","title":"Normal"}
{"id":"bd-2","title":"Also normal"}` {"id":"bd-2","title":"Also normal"}`
@@ -334,9 +322,9 @@ func TestValidateGitConflicts_Clean(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
// Override dbPath to point to temp dir // Override dbPath to point to temp file
originalDBPath := dbPath originalDBPath := dbPath
dbPath = filepath.Join(beadsDir, "beads.db") dbPath = jsonlPath
defer func() { dbPath = originalDBPath }() defer func() { dbPath = originalDBPath }()
result := validateGitConflicts(ctx, false) result := validateGitConflicts(ctx, false)