[test-improver] Improve tests for validateSingleAgentPolicy error paths - #12193
[test-improver] Improve tests for validateSingleAgentPolicy error paths#12193github-actions[bot] wants to merge 1 commit into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
The additive tests accurately cover the intended validation branches and follow existing conventions.
Pull request overview
Adds targeted coverage for validateSingleAgentPolicy validation paths.
Changes:
- Adds table-driven error-path tests.
- Verifies agent IDs remain redacted.
- Adds a valid-policy sanity test.
File summaries
| File | Description |
|---|---|
internal/config/agent_policy_test.go |
Expands policy validation coverage. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
🔒 mcpg Read-Only Stress — gVisorSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
No writes leaked. No test artifacts created.
|
🔒 mcpg Read-Only Stress — docker-sbxSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
No write leaked. No FAIL condition triggered.
|
🔒 mcpg Read-Only Stress — default AWFSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
No writes leaked. Run is INCONCLUSIVE (not FAIL) per the validation criteria.
|
Summary
Improved
internal/config/agent_policy_test.goby adding coverage for previously-untested error branches invalidateSingleAgentPolicy(internal/config/agent_policy.go).File analyzed
internal/config/agent_policy_test.go(testsinternal/config/agent_policy.go)Improvements made
Added two new test functions:
TestValidateSingleAgentPolicy_ErrorPaths— table-driven test covering:Servers: []string{""})ServerslistAllowOnlysub-policy (propagated validation error)TestValidateSingleAgentPolicy_ValidPolicySucceeds— a happy-path sanity check that a fully valid policy returns no error.All new tests use testify (
require.Error/assert.ErrorContains/assert.NotContains/assert.NoError), consistent with the existing file's conventions, and assert that the raw agent ID is never leaked into error messages (matching the existing whitespace test's behavior).Coverage before/after
validateSingleAgentPolicy: 87.5% → 100%internal/configpackage total: 96.9% → 97.1%Test output
Also verified:
go test -count=3 ./internal/config/...— all pass (stability check)go vet ./internal/config/— cleangofmt -l internal/config/agent_policy_test.go— no output (already formatted)No existing tests were modified or removed; all changes are additive.