[test] Add tests for server.parseToolArguments and related UnifiedServer methods#1655
Draft
github-actions[bot] wants to merge 1 commit intomainfrom
Draft
Conversation
…hods Cover previously untested functions in internal/server/unified.go: - parseToolArguments: all 3 code paths (nil args, valid JSON, invalid JSON) with 16 table-driven test cases covering edge cases (arrays, strings, numbers, booleans, nested objects, Unicode, error wrapping) - GetPayloadSizeThreshold: custom, zero (fallback), nil-gateway fallback, and large threshold scenarios - GetServerStatus: zero/one/multiple servers, map isolation check - IsDIFCEnabled: disabled (default) and enabled paths - SetHTTPShutdown / GetHTTPShutdown: nil default, setter, override, nil reset, and error propagation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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:
parseToolArgumentsand related methodsFunctions Analyzed
internal/serverparseToolArguments— 0% previous coverageGetPayloadSizeThreshold,GetServerStatus,IsDIFCEnabled,SetHTTPShutdown,GetHTTPShutdownWhy These Functions?
parseToolArgumentsinunified.gohad zero test coverage despite being a critical function that parses MCP tool arguments for registered handlers (includingsys___init). It has three distinct code paths:nilarguments → returns empty map (no-arg tool calls)map[string]interface{}The additional functions (
GetPayloadSizeThreshold,GetServerStatus,IsDIFCEnabled,SetHTTPShutdown/GetHTTPShutdown) are direct getters/setters onUnifiedServerthat were reachable in production but had no unit tests exercising them directly.Tests Added
TestParseToolArguments(16 table-driven cases):{}nullvalue for a keyTestParseToolArguments_NilArgumentsAlwaysReturnsNewMap:TestParseToolArguments_ErrorWrapping:"failed to parse arguments:"TestGetPayloadSizeThreshold(4 sub-tests):DefaultPayloadSizeThresholdTestGetServerStatus(3 table-driven + 1 mutation isolation):"running"statusTestIsDIFCEnabled:TestSetAndGetHTTPShutdown(5 sub-tests):Coverage Report
Test File
internal/server/parse_tool_arguments_test.gopackage server(same package, tests internal functions)t.Run()sub-tests, testifyassert/requireGenerated by Test Coverage Improver
Next run will target the next most complex under-tested function
Warning
The following domain was blocked by the firewall during workflow execution:
proxy.golang.org