[test] Add tests for config.validateGatewayConfig and validateTrustedBots#3637
Draft
github-actions[bot] wants to merge 1 commit intomainfrom
Draft
[test] Add tests for config.validateGatewayConfig and validateTrustedBots#3637github-actions[bot] wants to merge 1 commit intomainfrom
github-actions[bot] wants to merge 1 commit intomainfrom
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>
This was referenced Apr 12, 2026
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