Commit d649bbb
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]
> **0 file changed
0 commit comments