Commit a82d155
authored
test(component,generic,http): replace external httpbin.org dependency with local test server (#1101)
Because
- The unit tests were flaky, failing arbitrarily with 503 errors and
connection timeouts
- Tests depended on external httpbin.org service, making them unreliable
in CI/CD environments
- External network calls made tests slow (20+ seconds) and
non-deterministic
- Type conversion panics occurred when httpbin.org returned unexpected
response formats
This commit
- **Replaces httpbin.org with local httptest server**: Created
`createLocalTestServer()` that mimics all httpbin.org endpoints (JSON,
headers, text, binary, auth endpoints)
- **Eliminates external dependencies**: Tests now run completely offline
with zero network calls to external services
- **Adds test environment detection**: Implements `isTestEnvironment()`
to cleanly bypass URL validation during testing without modifying
production code
- **Improves test reliability**: Tests are now deterministic with
consistent responses and no more flaky failures
- **Enhances performance**: Test execution time reduced from 20+ seconds
to ~300ms
- **Maintains comprehensive coverage**: All HTTP methods, authentication
types, and edge cases still fully tested
- **Fixes type conversion issues**: Added safe type checking to prevent
panics when response format differs from expected
- **Enables parallel execution**: Each test gets its own server instance
to avoid port conflicts
The refactored tests are now fast, reliable, and completely
self-contained while maintaining full test coverage of the HTTP
component functionality.1 parent 6258080 commit a82d155
2 files changed
+261
-21
lines changed
0 commit comments