Skip to content

Commit 7958e2f

Browse files
committed
fix tests
1 parent 8a38a3a commit 7958e2f

File tree

6 files changed

+15
-13
lines changed

6 files changed

+15
-13
lines changed

mcp/cmd_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ func TestCmdTransport(t *testing.T) {
226226
&mcp.TextContent{Text: "Hi user"},
227227
},
228228
}
229-
if diff := cmp.Diff(want, got); diff != "" {
229+
if diff := cmp.Diff(want, got, ctrCmpOpts...); diff != "" {
230230
t.Errorf("greet returned unexpected content (-want +got):\n%s", diff)
231231
}
232232
if err := session.Close(); err != nil {

mcp/content_nil_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func TestContentUnmarshalNil(t *testing.T) {
7272
}
7373

7474
// Verify that the Content field was properly populated
75-
if cmp.Diff(tt.want, tt.content) != "" {
75+
if cmp.Diff(tt.want, tt.content, ctrCmpOpts...) != "" {
7676
t.Errorf("Content is not equal: %v", cmp.Diff(tt.content, tt.content))
7777
}
7878
})
@@ -222,3 +222,5 @@ func TestContentUnmarshalNilWithInvalidContent(t *testing.T) {
222222
})
223223
}
224224
}
225+
226+
var ctrCmpOpts = []cmp.Option{cmp.AllowUnexported(mcp.CallToolResult{})}

mcp/mcp_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func TestEndToEnd(t *testing.T) {
234234
&TextContent{Text: "hi user"},
235235
},
236236
}
237-
if diff := cmp.Diff(wantHi, gotHi); diff != "" {
237+
if diff := cmp.Diff(wantHi, gotHi, ctrCmpOpts...); diff != "" {
238238
t.Errorf("tools/call 'greet' mismatch (-want +got):\n%s", diff)
239239
}
240240

@@ -253,7 +253,7 @@ func TestEndToEnd(t *testing.T) {
253253
&TextContent{Text: errTestFailure.Error()},
254254
},
255255
}
256-
if diff := cmp.Diff(wantFail, gotFail); diff != "" {
256+
if diff := cmp.Diff(wantFail, gotFail, ctrCmpOpts...); diff != "" {
257257
t.Errorf("tools/call 'fail' mismatch (-want +got):\n%s", diff)
258258
}
259259

@@ -1717,7 +1717,7 @@ func TestPointerArgEquivalence(t *testing.T) {
17171717
if err != nil {
17181718
t.Fatal(err)
17191719
}
1720-
if diff := cmp.Diff(r0, r1); diff != "" {
1720+
if diff := cmp.Diff(r0, r1, ctrCmpOpts...); diff != "" {
17211721
t.Errorf("CallTool(%v) with no arguments mismatch (-%s +%s):\n%s", args, t0.Name, t1.Name, diff)
17221722
}
17231723
}
@@ -1733,7 +1733,7 @@ func TestPointerArgEquivalence(t *testing.T) {
17331733
if err != nil {
17341734
t.Fatal(err)
17351735
}
1736-
if diff := cmp.Diff(r0, r1); diff != "" {
1736+
if diff := cmp.Diff(r0, r1, ctrCmpOpts...); diff != "" {
17371737
t.Errorf("CallTool({\"In\": %q}) mismatch (-%s +%s):\n%s", in, t0.Name, t1.Name, diff)
17381738
}
17391739
})
@@ -1875,7 +1875,7 @@ func TestToolErrorMiddleware(t *testing.T) {
18751875
}
18761876
defer clientSession.Close()
18771877

1878-
res, err := clientSession.CallTool(ctx, &CallToolParams{
1878+
_, err = clientSession.CallTool(ctx, &CallToolParams{
18791879
Name: "greet",
18801880
Arguments: map[string]any{"Name": "al"},
18811881
})
@@ -1885,7 +1885,7 @@ func TestToolErrorMiddleware(t *testing.T) {
18851885
if middleErr != nil {
18861886
t.Errorf("middleware got error %v, want nil", middleErr)
18871887
}
1888-
res, err = clientSession.CallTool(ctx, &CallToolParams{
1888+
res, err := clientSession.CallTool(ctx, &CallToolParams{
18891889
Name: "fail",
18901890
})
18911891
if err != nil {
@@ -1902,3 +1902,5 @@ func TestToolErrorMiddleware(t *testing.T) {
19021902
t.Errorf("middleware got err %v, want errTestFailure", middleErr)
19031903
}
19041904
}
1905+
1906+
var ctrCmpOpts = []cmp.Option{cmp.AllowUnexported(CallToolResult{})}

mcp/protocol_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ func TestContentUnmarshal(t *testing.T) {
499499
if err := json.Unmarshal(data, out); err != nil {
500500
t.Fatal(err)
501501
}
502-
if diff := cmp.Diff(in, out); diff != "" {
502+
if diff := cmp.Diff(in, out, ctrCmpOpts...); diff != "" {
503503
t.Errorf("mismatch (-want, +got):\n%s", diff)
504504
}
505505
}

mcp/sse_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func TestSSEServer(t *testing.T) {
7070
&TextContent{Text: "hi user"},
7171
},
7272
}
73-
if diff := cmp.Diff(wantHi, gotHi); diff != "" {
73+
if diff := cmp.Diff(wantHi, gotHi, ctrCmpOpts...); diff != "" {
7474
t.Errorf("tools/call 'greet' mismatch (-want +got):\n%s", diff)
7575
}
7676

mcp/streamable_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func TestStreamableTransports(t *testing.T) {
159159
want := &CallToolResult{
160160
Content: []Content{&TextContent{Text: "hi foo"}},
161161
}
162-
if diff := cmp.Diff(want, got); diff != "" {
162+
if diff := cmp.Diff(want, got, ctrCmpOpts...); diff != "" {
163163
t.Errorf("CallTool() returned unexpected content (-want +got):\n%s", diff)
164164
}
165165

@@ -550,8 +550,6 @@ func resp(id int64, result any, err error) *jsonrpc.Response {
550550
}
551551
}
552552

553-
var ()
554-
555553
func TestStreamableServerTransport(t *testing.T) {
556554
// This test checks detailed behavior of the streamable server transport, by
557555
// faking the behavior of a streamable client using a sequence of HTTP

0 commit comments

Comments
 (0)