Daily Test Coverage Improver - Add tests for audit report helper functions #2586
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Daily Test Coverage Improver - Audit Report Helper Functions
This PR adds comprehensive unit tests for three previously untested helper functions in
pkg/cli/audit_report.go.Summary of Changes
Added unit tests for:
calculateDirectorySize()- Directory size calculation utilityparseDurationString()- Duration string parsing utilitytruncateString()- String truncation with ellipsisProblems Found
During coverage analysis, I identified three pure utility functions in
pkg/cli/audit_report.gothat had 0% test coverage:calculateDirectorySize()(line 281)parseDurationString()(line 298)truncateString()(line 550)These are low-hanging fruit for coverage improvement as they:
Actions Taken
Created
pkg/cli/audit_report_helpers_test.gowith:TestCalculateDirectorySize(4 test cases)TestParseDurationString(7 test cases)TestTruncateString(8 test cases)Test Coverage Results
Replicating the Test Coverage Measurements
Possible Other Areas for Future Improvement
Based on my coverage analysis, here are high-value targets for future test additions:
Low-Complexity Pure Functions (0% coverage):
pkg/cli/ci.go:IsRunningInCI()- Simple environment checkpkg/constants/constants.go- Constant definitions (easily testable)pkg/cli/audit_report.go:renderOverview()- Console rendering (can be tested with output capture)pkg/cli/audit_report.go:renderMetrics()- Metrics renderingMedium-Complexity Functions (low coverage):
5.
pkg/cli/audit_report.go:extractDownloadedFiles()- 27.8% coverage6.
pkg/workflow/validation.go:collectPackagesFromWorkflow()- 29.7% coverage7.
pkg/cli/logs.go:downloadRunArtifacts()- 33.3% coverageThese represent opportunities for incremental coverage improvements without requiring extensive mocking infrastructure.
Verification
All tests run successfully:
Bash Commands Run
Web Searches Performed
None - this work was based on static code analysis of the existing codebase.
Web Pages Fetched
None - this work was based on static code analysis of the existing codebase.
AI generated by Daily Test Coverage Improver