Skip to content

Commit d649bbb

Browse files
authored
[Repo Assist] test(config): add tests for config_env.go gateway env var parsers (#5197)
🤖 *This PR was created by Repo Assist, an automated AI assistant.* ## Summary `internal/config/config_env.go` contains five functions that parse gateway configuration from environment variables: - `GetGatewayPortFromEnv()` – parses `MCP_GATEWAY_PORT` - `GetGatewayDomainFromEnv()` – reads `MCP_GATEWAY_DOMAIN` - `GetGatewayAPIKeyFromEnv()` – reads `MCP_GATEWAY_API_KEY` - `GetGatewayToolTimeoutFromEnv()` – parses `MCP_GATEWAY_TOOL_TIMEOUT` - `toolTimeoutEnvOrDefault()` – fallback-to-default helper None of these had any test coverage before this PR. These are gateway entry-point validators and a bug here (e.g. accepting out-of-range ports or sub-minimum timeouts) would silently misconfigure the server. ## Tests Added **`TestGetGatewayPortFromEnv`** (8 cases) - Not set → error - Non-integer → error with "invalid MCP_GATEWAY_PORT value" - `0`, `-1`, `65536` → out-of-range error - `1`, `65535`, `3000` → valid, returns parsed int **`TestGetGatewayDomainFromEnv`** (3 cases) - Not set → `""` - Domain only → returned as-is - Domain + port → returned as-is **`TestGetGatewayAPIKeyFromEnv`** (2 cases) - Not set → `""` - Set → returned as-is **`TestGetGatewayToolTimeoutFromEnv`** (8 cases) - Not set → `(0, false, nil)` - Non-integer, `0`, `-1`, `9` → error - `10` (minimum), `60` (default), `600` → `(val, true, nil)` **`TestToolTimeoutEnvOrDefault`** (5 cases) - Not set → `DefaultToolTimeout` - Invalid string → `DefaultToolTimeout` - Below-minimum (5) → `DefaultToolTimeout` - Valid `120` → `120` - Minimum-valid `10` → `10` ## Test Status Tests are logically correct and follow the patterns established in this codebase (`t.Setenv`, table-driven, `testify/assert` + `require`). Local execution was not possible due to network restrictions in the CI sandbox (Go module downloads blocked), but these tests are simple pure-logic unit tests with no external dependencies beyond testify. > [!WARNING] > **⚠️ Firewall blocked 1 domain** > > The following domain was blocked by the firewall during workflow execution: > > - `proxy.golang.org` > > To allow these domains, add them to the `network.allowed` list in your workflow frontmatter: > > ```yaml > network: > allowed: > - defaults > - "proxy.golang.org" > ``` > > See [Network Configuration](https://github.github.com/gh-aw/reference/network/) for more information. > Generated by [Repo Assist](https://github.com/github/gh-aw-mcpg/actions/runs/25436543863/agentic_workflow) · ● 4.1M · [◷](https://github.com/search?q=repo%3Agithub%2Fgh-aw-mcpg+%22gh-aw-workflow-id%3A+repo-assist%22&type=pullrequests) > > To install this [agentic workflow](https://github.com/githubnext/agentics/blob/851905c06e905bf362a9f6cc54f912e3df747d55/workflows/repo-assist.md), run > ``` > gh aw add githubnext/agentics@851905c > ``` <!-- gh-aw-agentic-workflow: Repo Assist, engine: copilot, version: 1.0.21, model: auto, id: 25436543863, workflow_id: repo-assist, run: https://github.com/github/gh-aw-mcpg/actions/runs/25436543863 --> <!-- gh-aw-workflow-id: repo-assist -->
2 parents 03ad7d0 + 0ce0dd5 commit d649bbb

0 file changed

File tree

    0 commit comments

    Comments
     (0)