diff --git a/cmd/bd/duplicates_test.go b/cmd/bd/duplicates_test.go index 3d6a408c..cc900973 100644 --- a/cmd/bd/duplicates_test.go +++ b/cmd/bd/duplicates_test.go @@ -2,6 +2,7 @@ package main import ( "context" + "path/filepath" "testing" "github.com/steveyegge/beads/internal/types" @@ -199,13 +200,14 @@ func TestDuplicateGroupsWithDifferentStatuses(t *testing.T) { func TestDuplicatesIntegration(t *testing.T) { ctx := context.Background() - testStore, cleanup := setupTestDB(t) - defer cleanup() + tmpDir := t.TempDir() + testDB := filepath.Join(tmpDir, "test.db") + testStore := newTestStore(t, testDB) // Create duplicate issues issues := []*types.Issue{ { - ID: "bd-1", + ID: "test-1", Title: "Fix authentication bug", Description: "Users can't login", Status: types.StatusOpen, @@ -213,7 +215,7 @@ func TestDuplicatesIntegration(t *testing.T) { IssueType: types.TypeBug, }, { - ID: "bd-2", + ID: "test-2", Title: "Fix authentication bug", Description: "Users can't login", Status: types.StatusOpen, @@ -221,7 +223,7 @@ func TestDuplicatesIntegration(t *testing.T) { IssueType: types.TypeBug, }, { - ID: "bd-3", + ID: "test-3", Title: "Different task", Description: "Different description", Status: types.StatusOpen, @@ -253,13 +255,13 @@ func TestDuplicatesIntegration(t *testing.T) { t.Fatalf("Expected 2 issues in group, got %d", len(groups[0])) } - // Verify the duplicate group contains bd-1 and bd-2 + // Verify the duplicate group contains test-1 and test-2 ids := make(map[string]bool) for _, issue := range groups[0] { ids[issue.ID] = true } - if !ids["bd-1"] || !ids["bd-2"] { - t.Errorf("Expected duplicate group to contain bd-1 and bd-2") + if !ids["test-1"] || !ids["test-2"] { + t.Errorf("Expected duplicate group to contain test-1 and test-2") } } diff --git a/cmd/bd/epic_test.go b/cmd/bd/epic_test.go index 5b57298f..fe29b852 100644 --- a/cmd/bd/epic_test.go +++ b/cmd/bd/epic_test.go @@ -3,36 +3,19 @@ package main import ( "context" "fmt" - "os" "path/filepath" "testing" "time" - "github.com/steveyegge/beads/internal/storage/sqlite" "github.com/steveyegge/beads/internal/types" ) func TestEpicCommand(t *testing.T) { tmpDir := t.TempDir() - dbPath := filepath.Join(tmpDir, ".beads", "beads.db") - - if err := os.MkdirAll(filepath.Dir(dbPath), 0755); err != nil { - t.Fatal(err) - } - - sqliteStore, err := sqlite.New(context.Background(), dbPath) - if err != nil { - t.Fatal(err) - } - defer sqliteStore.Close() - + testDB := filepath.Join(tmpDir, ".beads", "beads.db") + sqliteStore := newTestStore(t, testDB) ctx := context.Background() - // Set issue_prefix - if err := sqliteStore.SetConfig(ctx, "issue_prefix", "test"); err != nil { - t.Fatalf("Failed to set issue_prefix: %v", err) - } - // Create an epic with children epic := &types.Issue{ ID: "test-epic-1", @@ -146,25 +129,10 @@ func TestEpicCommandInit(t *testing.T) { func TestEpicEligibleForClose(t *testing.T) { tmpDir := t.TempDir() - dbPath := filepath.Join(tmpDir, ".beads", "beads.db") - - if err := os.MkdirAll(filepath.Dir(dbPath), 0755); err != nil { - t.Fatal(err) - } - - sqliteStore, err := sqlite.New(context.Background(), dbPath) - if err != nil { - t.Fatal(err) - } - defer sqliteStore.Close() - + testDB := filepath.Join(tmpDir, ".beads", "beads.db") + sqliteStore := newTestStore(t, testDB) ctx := context.Background() - // Set issue_prefix - if err := sqliteStore.SetConfig(ctx, "issue_prefix", "test"); err != nil { - t.Fatalf("Failed to set issue_prefix: %v", err) - } - // Create an epic where all children are closed epic := &types.Issue{ ID: "test-epic-2",