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

stacklok / toolhive / 19311403055

12 Nov 2025 08:46PM UTC coverage: 48.921% (-0.001%) from 48.922%
19311403055

push

github

web-flow
Fix flaky TestGenerateUserAgent test using dependency injection (#2561)

The test was flaky due to race conditions from parallel subtests manipulating
the shared global environment variable KUBERNETES_SERVICE_HOST. This caused
intermittent failures when tests executed concurrently.

This fix refactors generateUserAgent() to use dependency injection with the
existing env.Reader interface, allowing tests to use isolated mock environment
readers instead of modifying global state. The tests now run reliably in
parallel without interference.

Changes:
- Add generateUserAgentWithEnv() that accepts an env.Reader parameter
- Keep generateUserAgent() as a wrapper using env.OSReader for production
- Update tests to use gomock-based environment readers
- Remove all os.Setenv/Unsetenv calls from tests
- Tests remain parallel and pass consistently with race detector

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>

4 of 4 new or added lines in 1 file covered. (100.0%)

2 existing lines in 1 file now uncovered.

24163 of 49392 relevant lines covered (48.92%)

35.71 hits per line

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

82.83
/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

© 2025 Coveralls, Inc