Repository navigation
[test-improver] Improve tests for httputil - #10547
Conversation
… error path Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds coverage for the previously untested os.Setenv failure path in TLS trust environment configuration.
Changes:
- Adds a NUL-containing CA path test.
- Verifies the wrapped error and affected environment key.
Show a summary per file
| File | Description |
|---|---|
internal/httputil/tls_test.go |
Tests propagation of os.Setenv failures. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Balanced
🔒 mcpg Read-Only Stress — defaultSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: PASS All 7 MCP write tools absent from gateway-filtered allowlist. All CLI/GraphQL writes blocked (unauthenticated gh). No writes leaked. Run: §30724631959
|
🔒 mcpg Read-Only Stress — docker-sbxSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: PASS
References: §30724631935
|
Summary
Improved
internal/httputil/tls_test.goto cover a previously-untested error branch inConfigureTLSTrustEnvironment.File analyzed
internal/httputil/tls_test.go(tests forinternal/httputil/tls.go)Coverage before/after
internal/httputilpackage coverage was 98.9%, withConfigureTLSTrustEnvironmentat 87.5% (theos.Setenverror-wrapping branch was untested).internal/httputilpackage coverage is 100.0%.Improvement made
Added a new subtest
propagates os.Setenv failuretoTestConfigureTLSTrustEnvironmentthat passes a CA path containing an embedded NUL byte (\x00), whichos.Setenvrejects withsetenv: invalid argumenton all supported platforms. This exercises thefmt.Errorf("failed to set %s: %w", key, err)wrapped-error return path that was otherwise unreachable given the existing newline/carriage-return validation guard.The test asserts:
require.Error)"failed to set"TLSTrustEnvKeys()[0])All existing tests, testify usage (
require/assert), and table-drivent.Runstructure were preserved unchanged.Test output
Verified with
go test -count=3 ./internal/httputil/,go vet ./internal/httputil/, andgofmt -l(no issues).