mcp: use synctest for timing-dependent tests (#756)
Converted timing-based tests to use Go 1.25's synctest for instant, deterministic execution with simulated time. Moved converted tests to *_go125_test.go files. Tests using real I/O (exec.Command, httptest) remain timing-based as they require actual system operations. Fixes #680 --------- Co-authored-by: i586147 <lakshana.goswami@sap.com>
This commit is contained in:
parent
41b54dced5
commit
86f8415122
1 changed files with 895 additions and 3 deletions
|
|
@ -76,6 +76,7 @@ func runCancelContextServer() {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: remove this test when Go 1.24 support is dropped (use go1.25 synctest version).
|
||||
func TestServerRunContextCancel(t *testing.T) {
|
||||
server := mcp.NewServer(&mcp.Implementation{Name: "greeter", Version: "v0.0.1"}, nil)
|
||||
mcp.AddTool(server, &mcp.Tool{Name: "greet", Description: "say hi"}, SayHi)
|
||||
|
|
@ -107,7 +108,7 @@ func TestServerRunContextCancel(t *testing.T) {
|
|||
cancel()
|
||||
|
||||
// wait for the server to exit
|
||||
// TODO: use synctest when availble
|
||||
// TODO: use synctest when available
|
||||
select {
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("server did not exit after context cancellation")
|
||||
|
|
|
|||
Loading…
Reference in a new issue