Files
beads/cmd/bd/doctor/fix/validation_test.go
Ryan a11b20960a fix(doctor): UX improvements for diagnostics and daemon (#687)
* fix(doctor): UX improvements for diagnostics and daemon

- Add Repo Fingerprint check to detect when database belongs to a
  different repository (copied .beads dir or git remote URL change)
- Add interactive fix for repo fingerprint with options: update repo ID,
  reinitialize database, or skip
- Add visible warning when daemon takes >5s to start, recommending
  'bd doctor' for diagnosis
- Detect install method (Homebrew vs script) and show only relevant
  upgrade command
- Improve WARNINGS section:
  - Add icons (⚠ or ✖) next to each item
  - Color numbers by severity (yellow for warnings, red for errors)
  - Render entire error lines in red
  - Sort by severity (errors first)
  - Fix alignment with checkmarks above
- Use heavier fail icon (✖) for better visibility
- Add integration and validation tests for doctor fixes

* fix(lint): address errcheck and gosec warnings

- mol_bond.go: explicitly ignore ephStore.Close() error
- beads.go: add nosec for .gitignore file permissions (0644 is standard)
2025-12-22 01:25:23 -08:00

38 lines
1.0 KiB
Go

package fix
import (
"testing"
)
// TestFixFunctions_RequireBeadsDir verifies all fix functions properly validate
// that a .beads directory exists before attempting fixes.
// This replaces 10+ individual "missing .beads directory" subtests.
func TestFixFunctions_RequireBeadsDir(t *testing.T) {
funcs := []struct {
name string
fn func(string) error
}{
{"GitHooks", GitHooks},
{"MergeDriver", MergeDriver},
{"Daemon", Daemon},
{"DBJSONLSync", DBJSONLSync},
{"DatabaseVersion", DatabaseVersion},
{"SchemaCompatibility", SchemaCompatibility},
{"SyncBranchConfig", SyncBranchConfig},
{"SyncBranchHealth", func(dir string) error { return SyncBranchHealth(dir, "beads-sync") }},
{"UntrackedJSONL", UntrackedJSONL},
{"MigrateTombstones", MigrateTombstones},
}
for _, tc := range funcs {
t.Run(tc.name, func(t *testing.T) {
// Use a temp directory without .beads
dir := t.TempDir()
err := tc.fn(dir)
if err == nil {
t.Errorf("%s should return error for missing .beads directory", tc.name)
}
})
}
}