[test-improver] Improve tests for tracing package#6716
Draft
github-actions[bot] wants to merge 1 commit into
Draft
[test-improver] Improve tests for tracing package#6716github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
Add missing coverage for: - parseOTLPHeadersWithDecoder: test invalid percent-encoding error path (url.PathUnescape failure → raw value preserved) - WrapHTTPHandler: test route cleared when pattern method mismatches request method (exercises else-branch setting route = "") - Additional tests for explicit decode/no-decode behaviour in parseOTLPHeadersWithDecoder Coverage: 96.4% → 97.6% Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Test Improvements: tracing package
Files Analyzed
internal/tracing/parse_headers_test.go,internal/tracing/http_test.gointernal/tracingImprovements Made
1. Increased Coverage
✅ Added
TestParseOTLPHeadersWithDecoder_InvalidPercentEncoding— exercises theurl.PathUnescapeerror branch inparseOTLPHeadersWithDecoder(previously uncovered). Verifies the raw value is preserved when percent-decoding fails (e.g.%GZis not valid percent-encoding).✅ Added
TestParseOTLPHeadersWithDecoder_ValidPercentEncoding— documents and verifies that well-formed percent-encoded values are decoded whendecodeValues=true.✅ Added
TestParseOTLPHeadersWithDecoder_NoDecoding— documents and verifies that percent-encoded values are preserved as-is whendecodeValues=false.✅ Added
TestWrapHTTPHandler_PatternMethodMismatch_ClearsRoute— exercises theelse { route = "" }branch inWrapHTTPHandler(previously uncovered). This path is triggered whenr.Patterncontains a method prefix that differs from the actual request method.Previous Coverage: 96.4%
New Coverage: 97.6%
Improvement: +1.2%
2. Better Testing Patterns
Test<Func>_<Scenario>conventionTest Execution
All tests pass:
All other Go tests continue to pass (
make test-all).Why These Changes?
The
internal/tracingpackage had two meaningful uncovered branches:parseOTLPHeadersWithDecoder— Theurl.PathUnescapeerror path was untested. This is a real defensive code path that protects against invalid percent-encoded OTLP header values arriving via theOTEL_EXPORTER_OTLP_HEADERSenvironment variable.WrapHTTPHandler— Theroute = ""else-branch when the pattern's HTTP method doesn't match the request method was untested. While this rarely occurs in normal mux routing, it is a defensive code path worth covering.Generated by Test Improver Workflow
Focuses on better patterns, increased coverage, and more stable tests
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
index.crates.ioSee Network Configuration for more information.