-
-
Notifications
You must be signed in to change notification settings - Fork 133
test: improve pkg/ui/markdown test coverage to 89% #1425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Add comprehensive tests for SplitMarkdownContent parser function - Add tests for all renderer functions including ASCII variants - Add tests for RenderWorkflow, RenderError, and RenderSuccess - Add tests for WithWidth option and NewTerminalMarkdownRenderer - Add complete test coverage for styles including applyStyleSafely - Add tests for GetDefaultStyle with various markdown configurations - Test pointer helper functions (stringPtr, boolPtr, uintPtr) - Test non-TTY fallback scenarios for rendering functions - Improve overall package coverage from 43.3% to 89.3% 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
… QF1008 - Access embedded StylePrimitive fields directly on StyleBlock - Fix style.Heading.StylePrimitive.Color to style.Heading.Color - Fix style.Document, H1, H2, H3 StylePrimitive references - Simplify CodeBlock.StyleBlock.Color access This addresses golangci-lint QF1008: could remove embedded field StylePrimitive from selector 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
…i-lint warning - Extract style verification logic into verifyStyleCustomizations helper function - Use early return to avoid nested if-else blocks - Reduces cyclomatic complexity from 5 to acceptable level - Maintains same test coverage and functionality 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Add periods to all comment lines (godot) - Pass AtmosConfiguration by pointer to avoid hugeParam warnings (gocritic) - Remove unnecessary embedded field selectors for StyleBlock (QF1008) - Remove unnecessary fmt.Sprintf for string concatenation (S1025) - Update all tests to use pointer references for AtmosConfiguration This reduces the number of linting issues and improves code quality 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Pass ansi.StyleConfig by pointer to avoid hugeParam warning - Use Terminal.MaxWidth instead of deprecated Docs.MaxWidth field - Add backward compatibility fallback for deprecated field Reduces linting issues from 24 to 10 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Warning This PR exceeds the recommended limit of 1,000 lines.Large PRs are difficult to review and may be rejected due to their size. Please verify that this PR does not address multiple issues. |
- Replace repetitive conditional color assignment with applyColorSafely helper - Rename applyStyleSafely to applyColorSafely for clarity - Simplifies code and reduces duplication - Maintains testability with proper unit tests - Addresses concern about non-DRY code pattern 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Fixed compilation errors in all files calling NewTerminalMarkdownRenderer and NewRenderer - Updated errors/error_funcs.go to pass atmosConfig as pointer - Updated internal/tui/templates files to pass pointer - Updated pkg/utils/markdown_utils.go to pass pointer - Updated test files to use pointer references - Removed deprecated Docs.MaxWidth fallback
- Revert NewRenderer and NewTerminalMarkdownRenderer to accept AtmosConfiguration by value - Update all call sites to pass by value instead of pointer - Maintains test coverage improvements (89.7% for pkg/ui/markdown) - Preserves applyColorSafely helper function and other test enhancements The pointer optimization will be handled in a separate PR to avoid mixing test improvements with API changes.
}) | ||
} | ||
|
||
// TestNewRendererErrorCases tests error handling in NewRenderer |
Check failure
Code scanning / golangci-lint
Comment should end in a period Error test
}) | ||
} | ||
|
||
// TestRenderErrorCases tests error handling in rendering methods |
Check failure
Code scanning / golangci-lint
Comment should end in a period Error test
}) | ||
} | ||
|
||
// TestNewTerminalMarkdownRendererEdgeCases tests edge cases for NewTerminalMarkdownRenderer |
Check failure
Code scanning / golangci-lint
Comment should end in a period Error test
} | ||
|
||
// verifyStyleCustomizations checks if style customizations were applied correctly. | ||
func verifyStyleCustomizations(t *testing.T, atmosConfig schema.AtmosConfiguration, style *ansi.StyleConfig) { |
Check failure
Code scanning / golangci-lint
hugeParam: atmosConfig is heavy (6160 bytes); consider passing it by pointer Error test
what
pkg/ui/markdown
packagewhy
pkg/ui/markdown
package had low test coverage (43.3%)Test Coverage Details
New Test Files Created
pkg/ui/markdown/parser_test.go
- Tests forSplitMarkdownContent
functionpkg/ui/markdown/styles_test.go
- Tests for styling functions and configurationsFunctions Now Tested
SplitMarkdownContent
- Markdown content parsingRenderAsciiWithoutWordWrap
- ASCII rendering without word wrappingRenderAscii
- ASCII rendering with word wrappingRenderWorkflow
- Workflow documentation renderingRenderError
- Error message rendering with stylingRenderSuccess
- Success message renderingWithWidth
- Renderer width configuration optionNewTerminalMarkdownRenderer
- Terminal-aware renderer creationapplyStyleSafely
- Safe style application with nil checksGetDefaultStyle
- Style configuration with customizationsstringPtr
,boolPtr
,uintPtr
)Coverage Metrics
🤖 Generated with Claude Code