Repository navigation
[test] Add tests for difc.CollectionLabeledData.ToResult - #16234
Conversation
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
Focused unit tests cover envelope preservation, deep-clone and array-replacement behavior, empty collections, and invalid replacement paths without reported active issues.
No open issues 🎉
What changed in this PR
Adds focused unit tests for CollectionLabeledData.ToResult in internal/difc, increasing coverage to exercise envelope preservation, deep-clone behavior, array replacement, empty collections, and error paths.
Changes:
- Covers item-only and envelope-preserving results.
- Verifies nested and array-element replacements without mutating original data.
- Exercises invalid paths and replacement errors.
| File | Description |
|---|---|
internal/difc/collection_to_result_test.go |
Adds comprehensive tests for CollectionLabeledData.ToResult and envelope replacement error handling. |
Review effort: Lite (auto)
🔒 mcpg Read-Only Stress — defaultSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE Part B: none of add_issue_comment, star_repository, issue_write, create_branch, create_or_update_file, create_pull_request appeared in the github CLI bridge 23-tool catalog (backend runs with GITHUB_READ_ONLY=1) - this proves backend config, not independently mcpg gateway-level DIFC/guard blocking. Parts D/E: gh auth status showed no authenticated host (GH_TOKEN unset in this job), so REST and GraphQL write attempts failed with an auth error before reaching GitHub API - the token-scope boundary could not be exercised this run. No reaction, star, issue, comment, branch, file, or PR was created on any surface; no write leaked.
|
Test Coverage Improvement: CollectionLabeledData.ToResult
Function Analyzed
internal/difcCollectionLabeledData.ToResult(resource.go)replaceCollectionAtPath, which has many error paths)Why This Function?
It was among the lowest-covered non-trivial functions (the
PreserveEnvelopebranch was never exercised). The remaining 0%-coverage items were trivial or test helpers.Tests Added (
internal/difc/collection_to_result_test.go)PreserveEnvelope: nested map replacement, with check that the original is not mutated (deep clone)replaceCollectionAtPathcoverage: 96.3%.Test Execution
go test ./internal/difc/ -run TestCollectionLabeledData_ToResult→ okGenerated by Test Coverage Improver
Warning
Firewall blocked 4 domains
The following domains were blocked by the firewall during workflow execution:
example.comnonexistent.localslow.example.comthishostdoesnotexist12345.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.