From 1168f661d1c937a63b6c9d1722d4e1a05e0e76b0 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Fri, 21 Nov 2025 14:48:41 -0500 Subject: [PATCH] fix: Add context.Background() to sqlite.New() calls in test files Multiple test files were still using the old sqlite.New(path) signature instead of the new sqlite.New(ctx, path) signature. This was causing compilation failures in the test suite. Fixed files: - internal/importer/importer_test.go - internal/importer/external_ref_test.go - internal/importer/timestamp_test.go - internal/rpc/limits_test.go - internal/rpc/list_filters_test.go - internal/rpc/rpc_test.go - internal/rpc/status_test.go - internal/syncbranch/syncbranch_test.go --- internal/importer/external_ref_test.go | 8 ++++---- internal/importer/importer_test.go | 16 ++++++++-------- internal/importer/timestamp_test.go | 4 ++-- internal/rpc/limits_test.go | 6 +++--- internal/rpc/list_filters_test.go | 2 +- internal/rpc/rpc_test.go | 4 ++-- internal/rpc/status_test.go | 2 +- internal/syncbranch/syncbranch_test.go | 2 +- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/internal/importer/external_ref_test.go b/internal/importer/external_ref_test.go index 240290c8..8a0d82b1 100644 --- a/internal/importer/external_ref_test.go +++ b/internal/importer/external_ref_test.go @@ -22,7 +22,7 @@ func TestImportWithExternalRef(t *testing.T) { dbPath := filepath.Join(tmpDir, "test.db") // Create database - store, err := sqlite.New(dbPath) + store, err := sqlite.New(context.Background(), dbPath) if err != nil { t.Fatalf("Failed to create database: %v", err) } @@ -106,7 +106,7 @@ func TestImportWithExternalRefDifferentID(t *testing.T) { dbPath := filepath.Join(tmpDir, "test.db") // Create database - store, err := sqlite.New(dbPath) + store, err := sqlite.New(context.Background(), dbPath) if err != nil { t.Fatalf("Failed to create database: %v", err) } @@ -197,7 +197,7 @@ func TestImportLocalIssueNotOverwrittenByExternalRef(t *testing.T) { dbPath := filepath.Join(tmpDir, "test.db") // Create database - store, err := sqlite.New(dbPath) + store, err := sqlite.New(context.Background(), dbPath) if err != nil { t.Fatalf("Failed to create database: %v", err) } @@ -295,7 +295,7 @@ func TestImportExternalRefTimestampCheck(t *testing.T) { dbPath := filepath.Join(tmpDir, "test.db") // Create database - store, err := sqlite.New(dbPath) + store, err := sqlite.New(context.Background(), dbPath) if err != nil { t.Fatalf("Failed to create database: %v", err) } diff --git a/internal/importer/importer_test.go b/internal/importer/importer_test.go index 8759f242..3c3c5019 100644 --- a/internal/importer/importer_test.go +++ b/internal/importer/importer_test.go @@ -563,7 +563,7 @@ func TestImportIssues_Basic(t *testing.T) { // Create temp database tmpDB := t.TempDir() + "/test.db" - store, err := sqlite.New(tmpDB) + store, err := sqlite.New(context.Background(), tmpDB) if err != nil { t.Fatalf("Failed to create store: %v", err) } @@ -609,7 +609,7 @@ func TestImportIssues_Update(t *testing.T) { ctx := context.Background() tmpDB := t.TempDir() + "/test.db" - store, err := sqlite.New(tmpDB) + store, err := sqlite.New(context.Background(), tmpDB) if err != nil { t.Fatalf("Failed to create store: %v", err) } @@ -673,7 +673,7 @@ func TestImportIssues_DryRun(t *testing.T) { ctx := context.Background() tmpDB := t.TempDir() + "/test.db" - store, err := sqlite.New(tmpDB) + store, err := sqlite.New(context.Background(), tmpDB) if err != nil { t.Fatalf("Failed to create store: %v", err) } @@ -709,7 +709,7 @@ func TestImportIssues_Dependencies(t *testing.T) { ctx := context.Background() tmpDB := t.TempDir() + "/test.db" - store, err := sqlite.New(tmpDB) + store, err := sqlite.New(context.Background(), tmpDB) if err != nil { t.Fatalf("Failed to create store: %v", err) } @@ -762,7 +762,7 @@ func TestImportIssues_Labels(t *testing.T) { ctx := context.Background() tmpDB := t.TempDir() + "/test.db" - store, err := sqlite.New(tmpDB) + store, err := sqlite.New(context.Background(), tmpDB) if err != nil { t.Fatalf("Failed to create store: %v", err) } @@ -806,7 +806,7 @@ func TestGetOrCreateStore_ExistingStore(t *testing.T) { ctx := context.Background() tmpDB := t.TempDir() + "/test.db" - store, err := sqlite.New(tmpDB) + store, err := sqlite.New(context.Background(), tmpDB) if err != nil { t.Fatalf("Failed to create store: %v", err) } @@ -830,7 +830,7 @@ func TestGetOrCreateStore_NewStore(t *testing.T) { tmpDB := t.TempDir() + "/test.db" // Create initial database - initStore, err := sqlite.New(tmpDB) + initStore, err := sqlite.New(context.Background(), tmpDB) if err != nil { t.Fatalf("Failed to create store: %v", err) } @@ -1003,7 +1003,7 @@ func TestConcurrentExternalRefImports(t *testing.T) { t.Skip("TODO(bd-gpe7): Test hangs due to database deadlock - needs investigation") t.Run("sequential imports with same external_ref are detected as updates", func(t *testing.T) { - store, err := sqlite.New(":memory:") + store, err := sqlite.New(context.Background(), ":memory:") if err != nil { t.Fatalf("Failed to create store: %v", err) } diff --git a/internal/importer/timestamp_test.go b/internal/importer/timestamp_test.go index 26da8550..e26e7ec9 100644 --- a/internal/importer/timestamp_test.go +++ b/internal/importer/timestamp_test.go @@ -18,7 +18,7 @@ func TestImportTimestampPrecedence(t *testing.T) { dbPath := filepath.Join(tmpDir, "test.db") // Initialize storage - store, err := sqlite.New(dbPath) + store, err := sqlite.New(context.Background(), dbPath) if err != nil { t.Fatalf("Failed to create storage: %v", err) } @@ -138,7 +138,7 @@ func TestImportSameTimestamp(t *testing.T) { tmpDir := t.TempDir() dbPath := filepath.Join(tmpDir, "test.db") - store, err := sqlite.New(dbPath) + store, err := sqlite.New(context.Background(), dbPath) if err != nil { t.Fatalf("Failed to create storage: %v", err) } diff --git a/internal/rpc/limits_test.go b/internal/rpc/limits_test.go index 0a563ca3..0191201a 100644 --- a/internal/rpc/limits_test.go +++ b/internal/rpc/limits_test.go @@ -30,7 +30,7 @@ func TestConnectionLimits(t *testing.T) { t.Fatal(err) } - store, err := sqlite.New(dbPath) + store, err := sqlite.New(context.Background(), dbPath) if err != nil { t.Fatal(err) } @@ -152,7 +152,7 @@ func TestRequestTimeout(t *testing.T) { t.Fatal(err) } - store, err := sqlite.New(dbPath) + store, err := sqlite.New(context.Background(), dbPath) if err != nil { t.Fatal(err) } @@ -208,7 +208,7 @@ func TestHealthResponseIncludesLimits(t *testing.T) { dbPath := filepath.Join(tmpDir, "test.db") socketPath := filepath.Join(tmpDir, "test.sock") - store, err := sqlite.New(dbPath) + store, err := sqlite.New(context.Background(), dbPath) if err != nil { t.Fatal(err) } diff --git a/internal/rpc/list_filters_test.go b/internal/rpc/list_filters_test.go index 60dcdb1a..a5871f69 100644 --- a/internal/rpc/list_filters_test.go +++ b/internal/rpc/list_filters_test.go @@ -31,7 +31,7 @@ func setupTestServerWithStore(t *testing.T) (*Server, *Client, *sqlitestorage.SQ os.Remove(socketPath) - store, err := sqlitestorage.New(dbPath) + store, err := sqlitestorage.New(context.Background(), dbPath) if err != nil { os.RemoveAll(tmpDir) t.Fatalf("Failed to create store: %v", err) diff --git a/internal/rpc/rpc_test.go b/internal/rpc/rpc_test.go index 8ffeb461..04d23701 100644 --- a/internal/rpc/rpc_test.go +++ b/internal/rpc/rpc_test.go @@ -37,7 +37,7 @@ func setupTestServer(t *testing.T) (*Server, *Client, func()) { // Ensure socket doesn't exist from previous failed test os.Remove(socketPath) - store, err := sqlitestorage.New(dbPath) + store, err := sqlitestorage.New(context.Background(), dbPath) if err != nil { os.RemoveAll(tmpDir) t.Fatalf("Failed to create store: %v", err) @@ -354,7 +354,7 @@ func TestSocketCleanup(t *testing.T) { dbPath := filepath.Join(tmpDir, "test.db") socketPath := filepath.Join(tmpDir, "bd.sock") - store, err := sqlitestorage.New(dbPath) + store, err := sqlitestorage.New(context.Background(), dbPath) if err != nil { t.Fatalf("Failed to create store: %v", err) } diff --git a/internal/rpc/status_test.go b/internal/rpc/status_test.go index 2fd89d70..35e48772 100644 --- a/internal/rpc/status_test.go +++ b/internal/rpc/status_test.go @@ -15,7 +15,7 @@ func TestStatusEndpoint(t *testing.T) { dbPath := filepath.Join(tmpDir, "test.db") socketPath := filepath.Join(tmpDir, "test.sock") - store, err := sqlite.New(dbPath) + store, err := sqlite.New(context.Background(), dbPath) if err != nil { t.Fatalf("failed to create storage: %v", err) } diff --git a/internal/syncbranch/syncbranch_test.go b/internal/syncbranch/syncbranch_test.go index 8e396827..07cef909 100644 --- a/internal/syncbranch/syncbranch_test.go +++ b/internal/syncbranch/syncbranch_test.go @@ -50,7 +50,7 @@ func TestValidateBranchName(t *testing.T) { func newTestStore(t *testing.T) *sqlite.SQLiteStorage { t.Helper() - store, err := sqlite.New("file::memory:?mode=memory&cache=private") + store, err := sqlite.New(context.Background(), "file::memory:?mode=memory&cache=private") if err != nil { t.Fatalf("Failed to create test database: %v", err) }