Daily Test Coverage Improver - Hetzner CSI Installer Coverage Enhancement#2091
Closed
botantler[bot] wants to merge 8 commits intomainfrom
Closed
Daily Test Coverage Improver - Hetzner CSI Installer Coverage Enhancement#2091botantler[bot] wants to merge 8 commits intomainfrom
botantler[bot] wants to merge 8 commits intomainfrom
Conversation
- Add tests for Install method with missing HCLOUD_TOKEN - Add comprehensive tests for Images method - Successfully extracting images from chart - Error handling when templating fails - Handling manifests with no images - Expand Uninstall tests to include error cases - Improve overall test structure with table-driven subtests Coverage improved from 9.3% to 44.2% (+34.9 percentage points)
Contributor
✅
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
|
@copilot fix ALL golangci-lint issues |
Contributor
|
@devantler I've opened a new pull request, #2092, to work on those changes. Once the pull request is ready, I'll request review from you. |
* Initial plan * fix: resolve all golangci-lint issues in hetzner-csi installer tests - Remove unused error variables - Use assert.AnError for error mocking instead of dynamic errors - Fix errcheck issues by checking os.Unsetenv return value - Use t.Setenv() instead of os.Setenv() for proper test cleanup - Add required whitespace before defer statement - Split TestHetznerCSIInstaller_Images into three separate functions to fix funlen - Use require.ErrorIs instead of assert.ErrorIs for error assertions All tests pass and coverage remains at 44.2% Co-authored-by: devantler <26203420+devantler@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: devantler <26203420+devantler@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds unit tests to raise coverage for the Hetzner CSI installer (pkg/svc/installer/hetzner-csi), focusing on exercising installer error paths and Helm-templating image extraction logic.
Changes:
- Expanded
Uninstalltests to cover success and uninstall failure error-wrapping. - Added an
Installtest case for missingHCLOUD_TOKEN. - Added
Imagestests for successful extraction, templating failure, and manifests without images.
Signed-off-by: Nikolai Emil Damm <nikolaiemildamm@icloud.com>
- Remove excessive whitespace alignment in OptionsHetzner and OptionsTalos struct tags - Add ireturn exclusion for k3d/registry.go in .golangci.yml - Remove stale //nolint:ireturn directives from k3d registry functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Goal and Rationale
This PR improves test coverage for the Hetzner CSI Installer (
pkg/svc/installer/hetzner-csi), which had critically low coverage at 9.3%. The Hetzner CSI installer is responsible for deploying Hetzner Cloud's Container Storage Interface driver to Kubernetes clusters running on Hetzner infrastructure, making it an important component for production deployments.Approach
Added comprehensive unit tests focusing on:
Install Method Error Handling
HCLOUD_TOKENenvironment variableImages Method Coverage
Uninstall Method Enhancement
All tests use mock-based isolation (mockery-generated mocks) to avoid external dependencies on Helm/Kubernetes, following the repository's established testing patterns.
Impact Measurement
Coverage Results
* Minimal overall impact due to package size relative to codebase
Function-Level Coverage
Note:
createHetznerSecretandhelmInstallOrUpgradeHetznerCSIrequire Kubernetes client mocking for full coverage, which is beyond the scope of this initial improvement.Trade-offs
Added Complexity:
Test Maintenance:
Benefits:
Validation
Test Execution
All tests pass successfully:
Coverage Measurement
Future Work
Additional Coverage Opportunities:
createHetznerSecret): Requires Kubernetes fake clientset for full integration testinghelmInstallOrUpgradeHetznerCSI): Needs repository addition and chart upgrade mockingSimilar Low-Coverage Packages:
pkg/svc/installer/cloudproviderkind(1.0%)pkg/svc/provider/hetzner(7.1%)pkg/svc/installer/localpathstorage(5.9%)Reproducibility
Setup
Run Tests
Expected Results
Part of: Daily Test Coverage Improver workflow
Related Discussion: #1826