Skip to content

Commit 8815f14

Browse files
committed
chore: explicit err checks
1 parent 8d5b20c commit 8815f14

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

server/server_race_test.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/mark3labs/mcp-go/mcp"
1111
"github.com/stretchr/testify/assert"
12+
"github.com/stretchr/testify/require"
1213
)
1314

1415
// TestRaceConditions attempts to trigger race conditions by performing
@@ -75,11 +76,15 @@ func TestRaceConditions(t *testing.T) {
7576
})
7677

7778
runConcurrentOperation(&wg, testDuration, "list-tools", func() {
78-
srv.handleListTools(ctx, "123", mcp.ListToolsRequest{})
79+
result, reqErr := srv.handleListTools(ctx, "123", mcp.ListToolsRequest{})
80+
require.Nil(t, reqErr, "List tools operation should not return an error")
81+
require.NotNil(t, result, "List tools result should not be nil")
7982
})
8083

8184
runConcurrentOperation(&wg, testDuration, "list-prompts", func() {
82-
srv.handleListPrompts(ctx, "123", mcp.ListPromptsRequest{})
85+
result, reqErr := srv.handleListPrompts(ctx, "123", mcp.ListPromptsRequest{})
86+
require.Nil(t, reqErr, "List prompts operation should not return an error")
87+
require.NotNil(t, result, "List prompts result should not be nil")
8388
})
8489

8590
// Add a persistent tool for testing tool calls
@@ -94,7 +99,9 @@ func TestRaceConditions(t *testing.T) {
9499
req := mcp.CallToolRequest{}
95100
req.Params.Name = "persistent-tool"
96101
req.Params.Arguments = map[string]interface{}{"param": "test"}
97-
srv.handleToolCall(ctx, "123", req)
102+
result, reqErr := srv.handleToolCall(ctx, "123", req)
103+
require.Nil(t, reqErr, "Tool call operation should not return an error")
104+
require.NotNil(t, result, "Tool call result should not be nil")
98105
})
99106

100107
runConcurrentOperation(&wg, testDuration, "add-resources", func() {
@@ -165,7 +172,9 @@ func TestConcurrentPromptAdd(t *testing.T) {
165172

166173
// Try to get the prompt - this would deadlock with a single mutex
167174
go func() {
168-
srv.handleGetPrompt(ctx, "123", req)
175+
result, reqErr := srv.handleGetPrompt(ctx, "123", req)
176+
require.Nil(t, reqErr, "Get prompt operation should not return an error")
177+
require.NotNil(t, result, "Get prompt result should not be nil")
169178
close(done)
170179
}()
171180

0 commit comments

Comments
 (0)