[test-improver] Improve tests for Guard (LabelAgent/LabelResource success paths) - #10950
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds successful WASM response coverage for guard labeling methods.
Changes:
- Adds minimal WASM success fixtures.
- Tests successful
LabelAgentandLabelResourceparsing. - Exercises nil and non-nil capability inputs.
Show a summary per file
| File | Description |
|---|---|
internal/guard/wasm_labels_success_test.go |
Adds WASM fixtures and success-path tests. |
Review details
Tip
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: 1
- Review effort level: Balanced
| // TestLabelResource_SuccessPath_NilCapabilities verifies that LabelResource still | ||
| // succeeds when caps is nil (the capabilities field is simply omitted from the | ||
| // WASM input), covering the complementary branch to the caps != nil case above. | ||
| func TestLabelResource_SuccessPath_NilCapabilities(t *testing.T) { |
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 address review feedback |
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Addressed in the latest commit. The |
🔒 mcpg Read-Only Stress — gVisorSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Gateway exposes only 22 read-only tools. Write tool calls return Overall: PASS References: §31394467821
|
🔒 mcpg Read-Only Stress — docker-sbxSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: PASS
References: §31394468184
|
🔒 mcpg Read-Only Stress — default AWFSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: PASS
References: §31394468103
|
File analyzed
internal/guard/wasm_labels.go(LabelAgentandLabelResourcemethods onWasmGuard), tested via a new fileinternal/guard/wasm_labels_success_test.go.Why this file
Existing tests in
internal/guard/wasm_dispatch_test.gothoroughly cover error paths forLabelAgent/LabelResource(failed guard, empty response, missing exports, invalid JSON, etc.) but had no happy-path test exercising a full successful WASM response. This left the success branches — final response parsing, debug logging, and return statements — completely uncovered.Improvements made
Added
internal/guard/wasm_labels_success_test.gocontaining:labelAgentSuccessWasm,labelResourceSuccessWasm) that write valid JSON responses ({"difc_mode": "strict"}and{"resource": {...}, "operation": "read"}respectively) into linear memory and return the byte count, using the existingsetupRawWasmModuletest helper (no new dependencies).TestLabelAgent_SuccessPath— exercisesLabelAgent's full success path with a validallow-onlypolicy, asserting the parsedDIFCModefield viarequire/assert(testify).TestLabelResource_SuccessPath— exercisesLabelResourcewith non-nilcaps(covering thecaps != nilcapability-injection branch) and asserts the parsed resource description andreadoperation.TestLabelResource_SuccessPath_NilCapabilities— complementary case withcaps == nil, covering the alternate branch.All new tests use testify
require/assertexclusively, consistent with project conventions.Coverage before/after (
internal/guardpackage,go tool cover -func)LabelAgentLabelResourceTest output
Full package suite:
No existing tests were modified or removed.