Add unit tests to improve cmd/bd CLI coverage (bd-llfl)
Added 479 lines of new tests: - utils_unit_test.go: Tests for utility functions (truncateString, pluralize, formatTimeAgo, containsLabel, extractIDSuffix, truncate, truncateDescription, showCleanupDeprecationHint, clearAutoFlushState) - hooks_test.go: Tests for FormatHookWarnings, isRebaseInProgress, hasBeadsJSONL - list_test.go: Tests for formatIssueLong, formatIssueCompact - version_tracking_test.go: Fixed flaky tests by setting BEADS_DIR env var to prevent git worktree detection from finding the actual .beads directory instead of the temp directory Coverage increased from 21.6% to 22.0%. The remaining 78% of untested code involves daemon/RPC operations, command handlers requiring database/daemon setup, and git operations that would require integration tests with mocked dependencies. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -134,6 +134,10 @@ func TestTrackBdVersion_FirstRun(t *testing.T) {
|
||||
t.Fatalf("Failed to create db file: %v", err)
|
||||
}
|
||||
|
||||
// Set BEADS_DIR to force FindBeadsDir to use our temp directory
|
||||
// This prevents finding the actual .beads in a git worktree
|
||||
t.Setenv("BEADS_DIR", beadsDir)
|
||||
|
||||
// Change to temp directory
|
||||
t.Chdir(tmpDir)
|
||||
|
||||
@@ -176,6 +180,10 @@ func TestTrackBdVersion_UpgradeDetection(t *testing.T) {
|
||||
t.Fatalf("Failed to create .beads: %v", err)
|
||||
}
|
||||
|
||||
// Set BEADS_DIR to force FindBeadsDir to use our temp directory
|
||||
// This prevents finding the actual .beads in a git worktree
|
||||
t.Setenv("BEADS_DIR", beadsDir)
|
||||
|
||||
// Change to temp directory
|
||||
t.Chdir(tmpDir)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user