Conversation
Cover three previously-untested branches of validateGatewayConfig: - PayloadSizeThreshold: < 1 rejected, >= 1 accepted, nil omitted - TrustedBots delegation: empty array, whitespace-only entries, valid bots - OpenTelemetry delegation: missing endpoint, non-HTTPS, invalid traceId/spanId Add direct unit tests for validateTrustedBots (all 4 branches: nil, empty, whitespace/empty string entry, and valid list). Add tests for expandTracingVariables nil fast-path and partial-field expansion (endpoint-only, traceId-only, spanId-only, headers-only, all-empty no-op, and undefined-variable error paths for each field). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds targeted unit tests to improve branch coverage for gateway configuration validation helpers in internal/config, focusing on previously untested paths.
Changes:
- Added table-driven tests for
validateGatewayConfigcoveringPayloadSizeThreshold,TrustedBots, and OpenTelemetry delegation. - Added direct unit tests for
validateTrustedBots. - Added tests for
expandTracingVariablesnil fast-path and partial-field expansion/error paths.
Show a summary per file
| File | Description |
|---|---|
| internal/config/validation_gateway_coverage_test.go | New tests covering previously uncovered branches in gateway validation and tracing variable expansion. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 1
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| // helper shared within this file; intPtr is declared in validation_string_patterns_test.go. |
There was a problem hiding this comment.
The comment about intPtr is confusing/inaccurate: this file doesn’t define a helper and intPtr is shared across multiple _test.go files via validation_string_patterns_test.go. Consider either removing this comment or rewording it to clearly state that intPtr is a package-level test helper defined in validation_string_patterns_test.go and reused here.
Suggested change
| // helper shared within this file; intPtr is declared in validation_string_patterns_test.go. | |
| // intPtr is a package-level test helper defined in | |
| // validation_string_patterns_test.go and reused in this file. |
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 Coverage Improvement:
validateGatewayConfig&validateTrustedBotsFunctions Analyzed
internal/configvalidateGatewayConfigvalidateTrustedBots,expandTracingVariablesvalidateGatewayConfighad zero test coverage;validateTrustedBotshad no direct unit tests;expandTracingVariablesnil/partial-field paths were untestedvalidateGatewayConfighas 8 distinct validation branches, with three previously completely uncoveredWhy These Functions?
validateGatewayConfigis the central config-validation entry point for gateway configuration in stdin JSON format. The existingTestValidateGatewayConfigcovered port, timeout, and payloadDir validation but left three non-trivial branches completely untested:PayloadSizeThreshold— rejected when< 1per spec §4.1.3.3, but no test verified the boundary or the error path.TrustedBotsdelegation — empty array and whitespace-only entries are spec violations (§4.1.3.4), butvalidateTrustedBotshad no direct unit tests.OpenTelemetrydelegation —validateOpenTelemetryConfigis well-tested in isolation, but the delegation path throughvalidateGatewayConfigwas never exercised.Tests Added
TestValidateGatewayConfig_PayloadSizeThreshold— nil (omitted), threshold=1 (boundary), threshold=524288 (default), 0 (rejected), -1 and large negative (rejected)TestValidateGatewayConfig_TrustedBots— nil (omitted), valid list, single bot, empty array (rejected), whitespace-only entry (rejected), empty string entry (rejected), second/third entry invalid (correct index in error)TestValidateGatewayConfig_OpenTelemetry— nil (omitted), valid HTTPS endpoint, traceId+spanId, missing endpoint (rejected), non-HTTPS (rejected), invalid traceId (rejected), all-zero traceId (rejected), invalid spanId (rejected), service name acceptedTestValidateTrustedBots— direct unit tests for all 4 branches (nil, empty, whitespace/tab-only, valid, multi-entry index verification)TestExpandTracingVariables_NilConfig— nil fast-path returns nil without panicTestExpandTracingVariables_PartialFields— per-field expansion (endpoint-only, traceId-only, spanId-only, headers-only, all-empty no-op, and undefined-variable errors for each field)Coverage Improvement
Test Execution
Tests are syntactically correct Go code using table-driven patterns and testify assertions, consistent with the existing test suite. They will execute as part of
make test-unitin any environment with modules available.Generated by Test Coverage Improver
Next run will target the next most complex under-tested function