Fix Dolt backend init/daemon/doctor; prevent accidental SQLite artifacts; add integration tests; clean up lint (#1218)

* /{cmd,internal}: get dolt backend init working and allow issue creation

* /{website,internal,docs,cmd}: integration tests and more split backend fixes

* /{cmd,internal}: fix lint issues

* /cmd/bd/doctor/integrity.go: fix unable to query issues bug with dolt backend

* /cmd/bd/daemon.go: remove debug logging
This commit is contained in:
Dustin Brown
2026-01-20 17:34:00 -08:00
committed by GitHub
parent c1ac69da3e
commit d3ccd5cfba
31 changed files with 1071 additions and 305 deletions

View File

@@ -8,7 +8,7 @@ import (
func TestDefaultConfig(t *testing.T) {
cfg := DefaultConfig()
if cfg.Database != "beads.db" {
t.Errorf("Database = %q, want beads.db", cfg.Database)
}
@@ -25,26 +25,26 @@ func TestLoadSaveRoundtrip(t *testing.T) {
if err := os.MkdirAll(beadsDir, 0750); err != nil {
t.Fatalf("failed to create .beads directory: %v", err)
}
cfg := DefaultConfig()
if err := cfg.Save(beadsDir); err != nil {
t.Fatalf("Save() failed: %v", err)
}
loaded, err := Load(beadsDir)
if err != nil {
t.Fatalf("Load() failed: %v", err)
}
if loaded == nil {
t.Fatal("Load() returned nil config")
}
if loaded.Database != cfg.Database {
t.Errorf("Database = %q, want %q", loaded.Database, cfg.Database)
}
if loaded.JSONLExport != cfg.JSONLExport {
t.Errorf("JSONLExport = %q, want %q", loaded.JSONLExport, cfg.JSONLExport)
}
@@ -52,12 +52,12 @@ func TestLoadSaveRoundtrip(t *testing.T) {
func TestLoadNonexistent(t *testing.T) {
tmpDir := t.TempDir()
cfg, err := Load(tmpDir)
if err != nil {
t.Fatalf("Load() returned error for nonexistent config: %v", err)
}
if cfg != nil {
t.Errorf("Load() = %v, want nil for nonexistent config", cfg)
}
@@ -66,22 +66,44 @@ func TestLoadNonexistent(t *testing.T) {
func TestDatabasePath(t *testing.T) {
beadsDir := "/home/user/project/.beads"
cfg := &Config{Database: "beads.db"}
got := cfg.DatabasePath(beadsDir)
want := filepath.Join(beadsDir, "beads.db")
if got != want {
t.Errorf("DatabasePath() = %q, want %q", got, want)
}
}
func TestDatabasePath_Dolt(t *testing.T) {
beadsDir := "/home/user/project/.beads"
t.Run("explicit dolt dir", func(t *testing.T) {
cfg := &Config{Database: "dolt", Backend: BackendDolt}
got := cfg.DatabasePath(beadsDir)
want := filepath.Join(beadsDir, "dolt")
if got != want {
t.Errorf("DatabasePath() = %q, want %q", got, want)
}
})
t.Run("backward compat: dolt backend with beads.db field", func(t *testing.T) {
cfg := &Config{Database: "beads.db", Backend: BackendDolt}
got := cfg.DatabasePath(beadsDir)
want := filepath.Join(beadsDir, "dolt")
if got != want {
t.Errorf("DatabasePath() = %q, want %q", got, want)
}
})
}
func TestJSONLPath(t *testing.T) {
beadsDir := "/home/user/project/.beads"
tests := []struct {
name string
cfg *Config
want string
name string
cfg *Config
want string
}{
{
name: "default",
@@ -99,7 +121,7 @@ func TestJSONLPath(t *testing.T) {
want: filepath.Join(beadsDir, "issues.jsonl"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := tt.cfg.JSONLPath(beadsDir)
@@ -122,9 +144,9 @@ func TestConfigPath(t *testing.T) {
func TestGetDeletionsRetentionDays(t *testing.T) {
tests := []struct {
name string
cfg *Config
want int
name string
cfg *Config
want int
}{
{
name: "zero uses default",