Fix all test failures from bd-166 (missing issue_prefix)
Completed bd-167: Fixed all tests that failed with 'database not initialized: issue_prefix config is missing' error. Changes: - Created test helper functions in 3 locations: * cmd/bd/test_helpers_test.go (already existed) * internal/rpc/test_helpers.go (new) * internal/storage/sqlite/test_helpers.go (new) - Updated all affected test files to use newTestStore(): * cmd/bd: comments, export, git_sync, label, list, reopen, direct_mode * internal/rpc: rpc_test, version_test * internal/storage/sqlite: sqlite_test, underlying_db_test - Fixed config test: updated flush-debounce default from 5s to 30s - Removed unused sqlite imports from test files All tests now passing ✅ Also: - Closed bd-167, bd-170 (cleanup of beads-* duplicates) - Removed corrupt backup files Amp-Thread-ID: https://ampcode.com/threads/T-4a8c6002-9384-45b6-81f6-2907d1e4c6c2 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/steveyegge/beads/internal/storage/sqlite"
|
||||
"github.com/steveyegge/beads/internal/types"
|
||||
)
|
||||
|
||||
@@ -21,10 +20,7 @@ func TestCommentsCommand(t *testing.T) {
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
testDB := filepath.Join(tmpDir, "test.db")
|
||||
s, err := sqlite.New(testDB)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create store: %v", err)
|
||||
}
|
||||
s := newTestStore(t, testDB)
|
||||
defer s.Close()
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/steveyegge/beads/internal/rpc"
|
||||
"github.com/steveyegge/beads/internal/storage/sqlite"
|
||||
"github.com/steveyegge/beads/internal/types"
|
||||
)
|
||||
|
||||
@@ -67,10 +66,7 @@ func TestFallbackToDirectModeEnablesFlush(t *testing.T) {
|
||||
testDBPath := filepath.Join(beadsDir, "test.db")
|
||||
|
||||
// Seed database with issues
|
||||
setupStore, err := sqlite.New(testDBPath)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create seed store: %v", err)
|
||||
}
|
||||
setupStore := newTestStore(t, testDBPath)
|
||||
|
||||
ctx := context.Background()
|
||||
target := &types.Issue{
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/steveyegge/beads/internal/storage/sqlite"
|
||||
"github.com/steveyegge/beads/internal/types"
|
||||
)
|
||||
|
||||
@@ -22,10 +21,7 @@ func TestExportCommand(t *testing.T) {
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
testDB := filepath.Join(tmpDir, "test.db")
|
||||
s, err := sqlite.New(testDB)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create store: %v", err)
|
||||
}
|
||||
s := newTestStore(t, testDB)
|
||||
defer s.Close()
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -228,10 +224,7 @@ func TestExportCommand(t *testing.T) {
|
||||
|
||||
// Create empty database
|
||||
emptyDBPath := filepath.Join(tmpDir, "empty.db")
|
||||
emptyStore, err := sqlite.New(emptyDBPath)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create empty store: %v", err)
|
||||
}
|
||||
emptyStore := newTestStore(t, emptyDBPath)
|
||||
defer emptyStore.Close()
|
||||
|
||||
// Test using exportToJSONLWithStore directly (daemon code path)
|
||||
|
||||
@@ -45,10 +45,7 @@ func TestGitPullSyncIntegration(t *testing.T) {
|
||||
}
|
||||
|
||||
clone1DBPath := filepath.Join(clone1BeadsDir, "test.db")
|
||||
clone1Store, err := sqlite.New(clone1DBPath)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create clone1 database: %v", err)
|
||||
}
|
||||
clone1Store := newTestStore(t, clone1DBPath)
|
||||
defer clone1Store.Close()
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -94,10 +91,7 @@ func TestGitPullSyncIntegration(t *testing.T) {
|
||||
// Initialize empty database in clone2
|
||||
clone2BeadsDir := filepath.Join(clone2Dir, ".beads")
|
||||
clone2DBPath := filepath.Join(clone2BeadsDir, "test.db")
|
||||
clone2Store, err := sqlite.New(clone2DBPath)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create clone2 database: %v", err)
|
||||
}
|
||||
clone2Store := newTestStore(t, clone2DBPath)
|
||||
defer clone2Store.Close()
|
||||
|
||||
if err := clone2Store.SetMetadata(ctx, "issue_prefix", "test"); err != nil {
|
||||
@@ -141,10 +135,7 @@ func TestGitPullSyncIntegration(t *testing.T) {
|
||||
|
||||
// In real usage, auto-import would trigger on next bd command
|
||||
// For this test, we'll manually import to simulate that behavior
|
||||
newStore, err := sqlite.New(clone2DBPath)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to reopen database: %v", err)
|
||||
}
|
||||
newStore := newTestStore(t, clone2DBPath)
|
||||
// Don't defer close - we'll reassign to clone2Store for the next test
|
||||
|
||||
// Manually import to simulate auto-import behavior
|
||||
|
||||
@@ -123,10 +123,7 @@ func TestLabelCommands(t *testing.T) {
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
testDB := filepath.Join(tmpDir, "test.db")
|
||||
s, err := sqlite.New(testDB)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create store: %v", err)
|
||||
}
|
||||
s := newTestStore(t, testDB)
|
||||
defer s.Close()
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -98,10 +98,7 @@ func TestListCommand(t *testing.T) {
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
testDB := filepath.Join(tmpDir, "test.db")
|
||||
s, err := sqlite.New(testDB)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create store: %v", err)
|
||||
}
|
||||
s := newTestStore(t, testDB)
|
||||
defer s.Close()
|
||||
|
||||
h := newListTestHelper(t, s)
|
||||
|
||||
@@ -101,10 +101,7 @@ func TestReopenCommand(t *testing.T) {
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
testDB := filepath.Join(tmpDir, "test.db")
|
||||
s, err := sqlite.New(testDB)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create store: %v", err)
|
||||
}
|
||||
s := newTestStore(t, testDB)
|
||||
defer s.Close()
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
Reference in New Issue
Block a user