[test] Add tests for proxy.response_transform missing branches#5564
Merged
Conversation
Add response_transform_test.go covering branches in rewrapSearchResponse,
rebuildGraphQLResponse, deepCloneJSON, and unwrapSingleObject that were
not exercised by the existing proxy_test.go tests:
- rewrapSearchResponse: 'repositories' key path, filteredItems not []interface{},
original with neither 'items' nor 'repositories' key
- rebuildGraphQLResponse: original map with no 'data' field
- deepCloneJSON: top-level []interface{} input, primitive/nil inputs
- unwrapSingleObject: nil filteredData
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds focused unit tests for internal/proxy/response_transform.go to exercise defensive branches that weren’t previously covered by the existing proxy tests, improving confidence in response-shaping behavior for search, GraphQL, and JSON cloning helpers.
Changes:
- Add targeted tests for
rewrapSearchResponseuncommon envelopes and type-guard branches. - Add a test for
rebuildGraphQLResponsewhen the original payload lacks adatafield. - Add tests for
deepCloneJSONtop-level slice + primitive/nil inputs, andunwrapSingleObjectnil filtered data.
Show a summary per file
| File | Description |
|---|---|
| internal/proxy/response_transform_test.go | New unit tests covering previously-unexercised branches in response transformation helpers. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 2
Comment on lines
+11
to
+12
| // "repositories" key when the original search envelope uses that field name | ||
| // (e.g. GitHub code-search responses: {"total_count": N, "repositories": [...]}). |
Comment on lines
+1
to
+8
| package proxy | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/github/gh-aw-mcpg/internal/difc" | ||
| "github.com/stretchr/testify/assert" | ||
| ) |
Collaborator
|
@copilot address review feedback |
Contributor
Addressed in 7fefe11. I updated |
This was referenced May 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Test Coverage Improvement:
response_transform.goFunction Analyzed
internal/proxyinternal/proxy/response_transform.gorewrapSearchResponse,rebuildGraphQLResponse,deepCloneJSON,unwrapSingleObjectWhy This Function?
response_transform.gocontains the core response-shaping logic for DIFC-filtered API responses. The existing tests inproxy_test.gocovered the happy paths but left several defensive branches untested:rewrapSearchResponsefilteredItemsis not[]interface{}rewrapSearchResponse"repositories"key (code-search)rewrapSearchResponse"items"nor"repositories"rebuildGraphQLResponse"data"fielddeepCloneJSON[]interface{}inputdeepCloneJSONunwrapSingleObjectfilteredDataTests Added
TestRewrapSearchResponse_Repositories— GitHub code-searchrepositorieskeyTestRewrapSearchResponse_FilteredItemsNotSlice— type-assertion guard for non-slice filtered dataTestRewrapSearchResponse_NeitherItemsNorRepositories— original has no known collection keyTestRebuildGraphQLResponse_NoDataField— original map missingdatakeyTestDeepCloneJSON_Slice— top-level slice deep-copy isolationTestDeepCloneJSON_Primitive— primitive and nil pass-throughTestUnwrapSingleObject_NilFilteredData— nil filtered data returns nilCoverage Impact
All previously-unreachable branches in
response_transform.goare now directly exercised. The file had no dedicated test file before this PR; the newresponse_transform_test.goprovides focused unit tests independent of the broader integration scenarios inproxy_test.go.Generated by Test Coverage Improver
Next run will target the next most complex under-tested function
Warning
Firewall blocked 7 domains
The following domains were blocked by the firewall during workflow execution:
go.opentelemetry.iogo.yaml.ingolang.orggoogle.golang.orggopkg.inproxy.golang.orgreleaseassets.githubusercontent.comSee Network Configuration for more information.