Fix remaining test database initialization errors (bd-207)

Fixed 38 tests failing with 'database not initialized: issue_prefix config is missing' by replacing manual sqlite.New() calls with test helper functions.

Modified files:
- dep_test.go (4 tests)
- merge_test.go (4 tests)
- export_import_test.go (4 instances)
- import_collision_test.go (10 instances)
- import_bug_test.go (1 instance)
- import_collision_regression_test.go (2 instances)
- import_idempotent_test.go (2 instances)
- init_test.go (4 instances)
- integrity_test.go (3 tests)
- main_test.go (multiple tests)

All database initialization errors are now resolved.
Remaining test failures (2) are unrelated to database initialization.

Amp-Thread-ID: https://ampcode.com/threads/T-a6b09458-b899-49eb-9a62-346fa67f62c7
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-10-27 20:00:49 -07:00
parent a6ecc87a09
commit 1e2e066dc4
10 changed files with 82 additions and 391 deletions

View File

@@ -27,15 +27,7 @@ func TestImportSimpleCollision(t *testing.T) {
}()
dbPath := filepath.Join(tmpDir, "test.db")
testStore, err := sqlite.New(dbPath)
if err != nil {
t.Fatalf("Failed to create storage: %v", err)
}
defer func() {
if err := testStore.Close(); err != nil {
t.Logf("Warning: failed to close store: %v", err)
}
}()
testStore := newTestStoreWithPrefix(t, dbPath, "bd")
ctx := context.Background()
@@ -139,15 +131,7 @@ func TestImportMultipleCollisions(t *testing.T) {
}()
dbPath := filepath.Join(tmpDir, "test.db")
testStore, err := sqlite.New(dbPath)
if err != nil {
t.Fatalf("Failed to create storage: %v", err)
}
defer func() {
if err := testStore.Close(); err != nil {
t.Logf("Warning: failed to close store: %v", err)
}
}()
testStore := newTestStoreWithPrefix(t, dbPath, "bd")
ctx := context.Background()
@@ -253,15 +237,7 @@ func TestImportDependencyUpdates(t *testing.T) {
}()
dbPath := filepath.Join(tmpDir, "test.db")
testStore, err := sqlite.New(dbPath)
if err != nil {
t.Fatalf("Failed to create storage: %v", err)
}
defer func() {
if err := testStore.Close(); err != nil {
t.Logf("Warning: failed to close store: %v", err)
}
}()
testStore := newTestStoreWithPrefix(t, dbPath, "bd")
ctx := context.Background()
@@ -399,15 +375,7 @@ func TestImportTextReferenceUpdates(t *testing.T) {
}()
dbPath := filepath.Join(tmpDir, "test.db")
testStore, err := sqlite.New(dbPath)
if err != nil {
t.Fatalf("Failed to create storage: %v", err)
}
defer func() {
if err := testStore.Close(); err != nil {
t.Logf("Warning: failed to close store: %v", err)
}
}()
testStore := newTestStoreWithPrefix(t, dbPath, "bd")
ctx := context.Background()
@@ -546,15 +514,7 @@ func TestImportChainDependencies(t *testing.T) {
}()
dbPath := filepath.Join(tmpDir, "test.db")
testStore, err := sqlite.New(dbPath)
if err != nil {
t.Fatalf("Failed to create storage: %v", err)
}
defer func() {
if err := testStore.Close(); err != nil {
t.Logf("Warning: failed to close store: %v", err)
}
}()
testStore := newTestStoreWithPrefix(t, dbPath, "bd")
ctx := context.Background()
@@ -648,15 +608,7 @@ func TestImportPartialIDMatch(t *testing.T) {
}()
dbPath := filepath.Join(tmpDir, "test.db")
testStore, err := sqlite.New(dbPath)
if err != nil {
t.Fatalf("Failed to create storage: %v", err)
}
defer func() {
if err := testStore.Close(); err != nil {
t.Logf("Warning: failed to close store: %v", err)
}
}()
testStore := newTestStoreWithPrefix(t, dbPath, "bd")
ctx := context.Background()
@@ -771,15 +723,7 @@ func TestImportExactMatch(t *testing.T) {
}()
dbPath := filepath.Join(tmpDir, "test.db")
testStore, err := sqlite.New(dbPath)
if err != nil {
t.Fatalf("Failed to create storage: %v", err)
}
defer func() {
if err := testStore.Close(); err != nil {
t.Logf("Warning: failed to close store: %v", err)
}
}()
testStore := newTestStoreWithPrefix(t, dbPath, "bd")
ctx := context.Background()
@@ -836,15 +780,7 @@ func TestImportMixedScenario(t *testing.T) {
}()
dbPath := filepath.Join(tmpDir, "test.db")
testStore, err := sqlite.New(dbPath)
if err != nil {
t.Fatalf("Failed to create storage: %v", err)
}
defer func() {
if err := testStore.Close(); err != nil {
t.Logf("Warning: failed to close store: %v", err)
}
}()
testStore := newTestStoreWithPrefix(t, dbPath, "bd")
ctx := context.Background()
@@ -922,15 +858,7 @@ func TestImportWithDependenciesInJSONL(t *testing.T) {
}()
dbPath := filepath.Join(tmpDir, "test.db")
testStore, err := sqlite.New(dbPath)
if err != nil {
t.Fatalf("Failed to create storage: %v", err)
}
defer func() {
if err := testStore.Close(); err != nil {
t.Logf("Warning: failed to close store: %v", err)
}
}()
testStore := newTestStoreWithPrefix(t, dbPath, "bd")
ctx := context.Background()
@@ -989,15 +917,7 @@ func TestImportCounterSyncAfterHighID(t *testing.T) {
}()
dbPath := filepath.Join(tmpDir, "test.db")
testStore, err := sqlite.New(dbPath)
if err != nil {
t.Fatalf("Failed to create storage: %v", err)
}
defer func() {
if err := testStore.Close(); err != nil {
t.Logf("Warning: failed to close store: %v", err)
}
}()
testStore := newTestStoreWithPrefix(t, dbPath, "bd")
ctx := context.Background()