From 571a596641a0604d2ffd8557f3812c593d783ec7 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Sun, 26 Oct 2025 23:06:03 -0700 Subject: [PATCH] Fix export test failures with ClearAllExportHashes for test isolation Amp-Thread-ID: https://ampcode.com/threads/T-5335d274-44e1-4811-b63f-15c52ea3394f Co-authored-by: Amp --- cmd/bd/export_test.go | 10 ++++++++++ internal/storage/sqlite/hash.go | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/cmd/bd/export_test.go b/cmd/bd/export_test.go index 49e6b3a7..5490b031 100644 --- a/cmd/bd/export_test.go +++ b/cmd/bd/export_test.go @@ -117,6 +117,11 @@ func TestExportCommand(t *testing.T) { t.Run("export includes labels", func(t *testing.T) { exportPath := filepath.Join(tmpDir, "export_labels.jsonl") + // Clear export hashes to force re-export (test isolation) + if err := s.ClearAllExportHashes(ctx); err != nil { + t.Fatalf("Failed to clear export hashes: %v", err) + } + store = s dbPath = testDB exportCmd.Flags().Set("output", exportPath) @@ -152,6 +157,11 @@ func TestExportCommand(t *testing.T) { t.Run("export includes dependencies", func(t *testing.T) { exportPath := filepath.Join(tmpDir, "export_deps.jsonl") + // Clear export hashes to force re-export (test isolation) + if err := s.ClearAllExportHashes(ctx); err != nil { + t.Fatalf("Failed to clear export hashes: %v", err) + } + store = s dbPath = testDB exportCmd.Flags().Set("output", exportPath) diff --git a/internal/storage/sqlite/hash.go b/internal/storage/sqlite/hash.go index cf050af4..41cd58ae 100644 --- a/internal/storage/sqlite/hash.go +++ b/internal/storage/sqlite/hash.go @@ -71,3 +71,13 @@ func (s *SQLiteStorage) SetExportHash(ctx context.Context, issueID, contentHash return nil } + +// ClearAllExportHashes removes all export hashes from the database. +// This is primarily used for test isolation to force re-export of issues. +func (s *SQLiteStorage) ClearAllExportHashes(ctx context.Context) error { + _, err := s.db.ExecContext(ctx, `DELETE FROM export_hashes`) + if err != nil { + return fmt.Errorf("failed to clear export hashes: %w", err) + } + return nil +}