Skip to content

Commit 3faf481

Browse files
JAORMXclaude
andcommitted
Add comprehensive tests for type conversion logic
Adds critical tests for the MCP SDK type conversions that are the most error-prone parts of the backend client implementation. Changes: - Add conversions_test.go with 8 test functions covering: - ToolInputSchema struct → map[string]any conversion - Content interface handling (AsTextContent, AsImageContent) - ResourceContents extraction (text and blob) - Prompt message concatenation - GetPrompt arguments conversion (map[string]any → map[string]string) - Resource MIMEType field name verification - Multiple content items handling - Prompt argument conversion - Fix flaky conflict resolution test - Accept either backend for shared tools (map iteration is non-deterministic) - More resilient assertion that doesn't assume iteration order Test Coverage: - Client: 13 test functions, 19 scenarios - Aggregator: 5 test functions, 8 scenarios - Discoverer: 1 test function, 8 scenarios - Total: 19 test functions, 35 test scenarios - All tests parallel-safe and run 10 times successfully 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 7629d62 commit 3faf481

File tree

2 files changed

+634
-2
lines changed

2 files changed

+634
-2
lines changed

pkg/vmcp/aggregator/default_aggregator_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,11 @@ func TestDefaultAggregator_ResolveConflicts(t *testing.T) {
249249
assert.Contains(t, resolved.Tools, "tool1")
250250
assert.Contains(t, resolved.Tools, "tool2")
251251
assert.Contains(t, resolved.Tools, "shared_tool")
252-
// Shared tool should have one backend (first encountered)
253-
assert.Equal(t, "backend1", resolved.Tools["shared_tool"].BackendID)
252+
// Shared tool should have one backend (whichever was encountered first in map iteration)
253+
// Map iteration order is non-deterministic, so accept either backend
254+
sharedToolBackend := resolved.Tools["shared_tool"].BackendID
255+
assert.True(t, sharedToolBackend == "backend1" || sharedToolBackend == "backend2",
256+
"shared_tool should belong to either backend1 or backend2, got: %s", sharedToolBackend)
254257
})
255258

256259
t.Run("no conflicts", func(t *testing.T) {

0 commit comments

Comments
 (0)