[test-improver] Improve tests for Guard - #11520
Conversation
…alidation Adds table-driven test cases exercising the previously-uncovered signature-validation error branches for label_response and label_agent in NewWasmGuardWithOptions (wasm_lifecycle.go). Only label_resource's bad-signature branch was previously tested. - New WASM fixtures: labelResponseBadSignatureWasm, labelAgentBadSignatureWasm - New table-driven test: TestNewWasmGuardWithOptions_InvalidSignature_TableDriven - Coverage: internal/guard 95.9% -> 96.4%; NewWasmGuardWithOptions 84.9% -> 92.5% Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds coverage for all WASM guard export signature-validation branches.
Changes:
- Adds invalid
label_responseandlabel_agentWASM fixtures. - Adds table-driven coverage for all three required exports.
Show a summary per file
| File | Description |
|---|---|
internal/guard/wasm_new_options_coverage_test.go |
Expands invalid-signature test coverage. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Balanced
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@copilot fix this failing ci check https://github.com/github/gh-aw-mcpg/actions/runs/32315996630/job/96384462686?pr=11520 |
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Fixed in commit I investigated the failing CI job logs and applied a minimal test-only fix in Validation run:
|
🔒 mcpg Read-Only Stress — gVisorSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
Run: §32390547791
|
🔒 mcpg Read-Only Stress — docker-sbxSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
Run ID: §32390547844
|
🔒 mcpg Read-Only Stress — default AWFSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
No write leaked through in any part. Run ID: 32390547797
|
Summary
Improved test coverage for
internal/guard/wasm_new_options_coverage_test.go, which testsNewWasmGuardWithOptionsininternal/guard/wasm_lifecycle.go.File analyzed
internal/guard/wasm_lifecycle.go—NewWasmGuardWithOptionsvalidates that exported WASM guard functions (label_resource,label_response,label_agent) have the expected signature(i32,i32,i32,i32)->i32, returning a descriptive error otherwise.label_resourcebad-signature branch (viaTestNewWasmGuardWithOptions_InvalidExportedFunctionSignature). Thelabel_responseandlabel_agentsignature-validation error branches (lines 405-408 and 409-412) were uncovered.Improvements made
labelResponseBadSignatureWasm— validlabel_resource/label_agent, butlabel_responsehas signature()->()instead of the required ABI.labelAgentBadSignatureWasm— validlabel_resource/label_response, butlabel_agenthas signature()->().label_resource-only case with a new table-driven test,TestNewWasmGuardWithOptions_InvalidSignature_TableDriven, usingt.Runsubtests and bound asserters (assert := assert.New(t),require := require.New(t)) to cover all three signature-validation branches (label_resource,label_response,label_agent) in one structured test.Coverage before/after
internal/guard: 95.9% → 96.4%NewWasmGuardWithOptions: 84.9% → 92.5%Test output
Notes
Verified with
GOTOOLCHAIN=autosince the localgotoolchain (1.24.13) is older thango.mod's requirement (1.26.4); Go's automatic toolchain download handled this transparently.