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