Improve test coverage for cmd/bd
- Add comprehensive version mismatch tests (checkVersionMismatch: 25% → 100%) - Add daemon formatting helper tests (formatDaemonDuration, formatDaemonRelativeTime: 0% → 100%) - Add auto-import test cases (checkAndAutoImport: 27.8% → 44.4%) - Add compact eligibility test Overall coverage: 47.9% → 48.3% cmd/bd coverage: 20.5% → 21.0% New test files: - cmd/bd/autoflush_version_test.go (5 test functions) - cmd/bd/daemons_test.go (2 test functions) All tests passing. Amp-Thread-ID: https://ampcode.com/threads/T-29fa5379-fd71-4f75-bc4f-272beff96c8f Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -67,6 +67,41 @@ func TestCheckAndAutoImport_DatabaseHasIssues(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckAndAutoImport_EmptyDatabaseNoGit(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
tmpDir := t.TempDir()
|
||||
tmpDB := filepath.Join(tmpDir, "test.db")
|
||||
store, err := sqlite.New(tmpDB)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create store: %v", err)
|
||||
}
|
||||
defer store.Close()
|
||||
|
||||
// Set prefix
|
||||
if err := store.SetConfig(ctx, "issue_prefix", "test"); err != nil {
|
||||
t.Fatalf("Failed to set prefix: %v", err)
|
||||
}
|
||||
|
||||
oldNoAutoImport := noAutoImport
|
||||
oldJsonOutput := jsonOutput
|
||||
noAutoImport = false
|
||||
jsonOutput = true // Suppress output
|
||||
defer func() {
|
||||
noAutoImport = oldNoAutoImport
|
||||
jsonOutput = oldJsonOutput
|
||||
}()
|
||||
|
||||
// Change to temp dir (no git repo)
|
||||
oldWd, _ := os.Getwd()
|
||||
defer os.Chdir(oldWd)
|
||||
os.Chdir(tmpDir)
|
||||
|
||||
result := checkAndAutoImport(ctx, store)
|
||||
if result {
|
||||
t.Error("Expected auto-import to skip when no git repo")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFindBeadsDir(t *testing.T) {
|
||||
// Create temp directory with .beads
|
||||
tmpDir := t.TempDir()
|
||||
|
||||
Reference in New Issue
Block a user