• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stacklok / toolhive / 17578201311

09 Sep 2025 09:29AM UTC coverage: 38.686% (+0.3%) from 38.371%
17578201311

push

github

web-flow
Improve test coverage and fix label validation bug (#1788)

This commit addresses test coverage improvements and fixes a critical bug in label validation:

- **Label validation bug**: Fixed ParseLabel to properly reject labels with multiple equals signs (e.g., 'key=value=extra')
- **Unified label parsing**: Removed redundant ParseLabelWithValidation function and made ParseLabel always validate
- **Race condition fix**: Refactored version.go to extract testable functions without global state dependencies

- Added comprehensive tests for pkg/versions/version.go (100% coverage)
- Added tests for pkg/transport/types/transport.go utilities
- Added tests for pkg/networking/utilities.go functions (AddressReferencesPrivateIp, ValidateEndpointURL)
- Added tests for pkg/transport/ssecommon/sse_common.go SSE message utilities (100% coverage)
- Added tests for pkg/core/workload.go SortWorkloadsByName function
- Added tests for pkg/workloads/types/labels.go label filtering utilities

- Refactored validateEndpointURLWithSkip to be testable without environment variables
- Improved error handling and validation consistency across label parsing
- Added proper parallel test execution with t.Parallel()
- Fixed linting issues and import organization

- Systematically improved coverage for utility functions across multiple packages
- Focus on easy-to-test functions that provide good coverage gains
- All new tests include edge cases and error conditions

The label validation bug was discovered through testing - labels with multiple equals signs were incorrectly parsed as valid, which could lead to security and parsing issues.

Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>

20 of 28 new or added lines in 4 files covered. (71.43%)

24 existing lines in 3 files now uncovered.

11407 of 29486 relevant lines covered (38.69%)

17.34 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.15
/pkg/transport/proxy/httpsse/http_proxy.go


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc