Skip to content

[test] Add tests for difc.CollectionLabeledData.ToResult - #16234

Merged
lpcox merged 1 commit into
mainfrom
test/collection-to-result-coverage-c184006000f7d774
Nov 9, 2026
Merged

lpcox merged 1 commit into
mainfrom
test/collection-to-result-coverage-c184006000f7d774

Conversation

@github-actions

@github-actions github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Test Coverage Improvement: CollectionLabeledData.ToResult

Function Analyzed

  • Package: internal/difc
  • Function: CollectionLabeledData.ToResult (resource.go)
  • Previous Coverage: 80.0%
  • New Coverage: 100.0%
  • Complexity: Medium (envelope branch delegates to replaceCollectionAtPath, which has many error paths)

Why This Function?

It was among the lowest-covered non-trivial functions (the PreserveEnvelope branch was never exercised). The remaining 0%-coverage items were trivial or test helpers.

Tests Added (internal/difc/collection_to_result_test.go)

  • ✅ No envelope: items only / empty collection
  • ✅ PreserveEnvelope: nested map replacement, with check that the original is not mutated (deep clone)
  • ✅ Empty items path returns items; array-element replacement
  • ✅ Error paths: missing keys, invalid/out-of-range indices, non-navigable/non-replaceable values

replaceCollectionAtPath coverage: 96.3%.

Test Execution

go test ./internal/difc/ -run TestCollectionLabeledData_ToResult → ok


Generated by Test Coverage Improver

Warning

Firewall blocked 4 domains

The following domains were blocked by the firewall during workflow execution:

  • example.com
  • nonexistent.local
  • slow.example.com
  • thishostdoesnotexist12345.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "example.com"
    - "nonexistent.local"
    - "slow.example.com"
    - "thishostdoesnotexist12345.com"

See Network Configuration for more information.

Generated by Test Coverage Improver · copilot · auto (Claude Sonnet 5.5) · ~48 AIC · ⊞ 11.5K · ◷

@lpcox
lpcox marked this pull request as ready for review November 9, 2026 17:01
Copilot AI adaptive review requested due to automatic review settings November 9, 2026 17:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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)

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

🔒 mcpg Read-Only Stress — default

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: default AWF (normal container isolation)

Part Surface Op Result Expected Status
A MCP reads data ALLOWED OK
B MCP writes (reaction/star/issue/comment/branch/file/PR) all 6 write tools absent from 23-tool catalog BLOCKED INCONCLUSIVE
C CLI reads data ALLOWED OK
D CLI REST writes (reaction/star/issue/comment) gh CLI unauthenticated (no GH_TOKEN) BLOCKED INCONCLUSIVE
E CLI GraphQL mutations (addReaction/addStar/createIssue) gh CLI unauthenticated BLOCKED INCONCLUSIVE

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.

🔒 mcpg read-only stress (default AWF runtime) by Read-Only Stress: default runtime

@lpcox
lpcox merged commit e8ac8fa into main Nov 9, 2026
28 checks passed
@lpcox
lpcox deleted the test/collection-to-result-coverage-c184006000f7d774 branch November 9, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants