Skip to content

[Repo Assist] test: add unit tests for ConvertToCallToolResult, ParseToolArguments, and sink server IDs#2160

Merged
lpcox merged 1 commit intomainfrom
repo-assist/improve-test-coverage-tool-result-sink-ids-14531a220dc9b827
Mar 19, 2026
Merged

[Repo Assist] test: add unit tests for ConvertToCallToolResult, ParseToolArguments, and sink server IDs#2160
lpcox merged 1 commit intomainfrom
repo-assist/improve-test-coverage-tool-result-sink-ids-14531a220dc9b827

Conversation

@github-actions
Copy link
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Adds unit tests for two previously untested modules:

internal/mcp/tool_result_test.go

Tests ConvertToCallToolResult — the backend result conversion function:

  • JSON array input is wrapped as a single TextContent item
  • Standard MCP format with text content items is converted correctly
  • Empty content array is preserved as zero items
  • isError: true is propagated to the result
  • Object without a content field is wrapped as text
  • Unknown content types (e.g. "image") fall back to text
  • Simple string input is wrapped as text

Tests ParseToolArguments — argument extraction from CallToolRequest:

  • Nil Arguments returns an empty map (not nil)
  • Valid JSON is parsed into the expected map
  • Nested object arguments are parsed correctly
  • Invalid JSON returns a descriptive error
  • Empty JSON object {} returns empty map

internal/difc/sink_server_ids_test.go

Tests SetSinkServerIDs:

  • Empty/nil slice clears previous configuration
  • Configured IDs match correctly
  • Unconfigured IDs do not match
  • Duplicates are deduplicated
  • Empty strings in input are skipped
  • Calling again replaces previous configuration

Tests IsSinkServerID:

  • Returns false when no IDs are configured
  • Returns true for exact match
  • Returns false for partial/prefix/suffix matches
  • Is case-sensitive
  • Is safe under concurrent access (sync.WaitGroup goroutine test)

Test Status

⚠️ Infrastructure note: The environment has Go 1.24.13 but go.mod requires Go 1.25.0 (the toolchain download is blocked by the network firewall). Tests could not be executed locally. Both files pass gofmt formatting checks. The logic follows established patterns in the codebase and the tests are straightforward unit tests of pure functions / simple concurrent state.

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@851905c06e905bf362a9f6cc54f912e3df747d55

Warning

⚠️ Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • proxy.golang.org

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

network:
  allowed:
    - defaults
    - "proxy.golang.org"

See Network Configuration for more information.

… and sink server IDs

Add tests for two untested functions:

- internal/mcp/tool_result_test.go: tests ConvertToCallToolResult
  (JSON array wrapping, standard MCP content conversion, empty content,
  isError propagation, unknown type fallback, no-content-field wrapping)
  and ParseToolArguments (nil args, valid JSON, nested objects, invalid
  JSON error, empty object).

- internal/difc/sink_server_ids_test.go: tests SetSinkServerIDs
  (clear on empty/nil, match configured IDs, deduplication, empty string
  skip, replace previous config) and IsSinkServerID (no config, exact
  match, partial non-match, case sensitivity, concurrent safety).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lpcox lpcox marked this pull request as ready for review March 19, 2026 15:47
Copilot AI review requested due to automatic review settings March 19, 2026 15:47
@lpcox lpcox merged commit a8dd4e1 into main Mar 19, 2026
3 checks passed
@lpcox lpcox deleted the repo-assist/improve-test-coverage-tool-result-sink-ids-14531a220dc9b827 branch March 19, 2026 15:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds new unit test coverage for MCP tool-result handling and DIFC sink server ID configuration, strengthening validation of core conversion/parsing helpers and the sink-ID matching behavior.

Changes:

  • Added unit tests for ConvertToCallToolResult covering common backend payload shapes and edge cases.
  • Added unit tests for ParseToolArguments covering nil/valid/invalid JSON argument handling.
  • Added unit tests for SetSinkServerIDs / IsSinkServerID covering clearing, dedup/skip-empty behavior, and matching semantics.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
internal/mcp/tool_result_test.go Adds unit tests for tool result conversion and tool-argument parsing helpers.
internal/difc/sink_server_ids_test.go Adds unit tests for sink server ID configuration and matching behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

result, err := ConvertToCallToolResult(nil)

require.NoError(t, err)
require.NotNil(t, result)
Comment on lines +107 to +111
wg.Add(1)
go func() {
defer wg.Done()
_ = IsSinkServerID("concurrent-server")
}()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants