Skip to content

Commit 5c2384a

Browse files
committed
ut
1 parent 26799d0 commit 5c2384a

File tree

1 file changed

+0
-47
lines changed

1 file changed

+0
-47
lines changed

server/streamable_http_test.go

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package server
22

33
import (
4-
"bufio"
54
"bytes"
65
"context"
76
"encoding/json"
@@ -455,52 +454,6 @@ func TestStreamableHTTP_POST_SendAndReceive_stateless(t *testing.T) {
455454
})
456455
}
457456

458-
func TestStreamableHTTP_GET(t *testing.T) {
459-
mcpServer := NewMCPServer("test-mcp-server", "1.0")
460-
addSSETool(mcpServer)
461-
server := NewTestStreamableHTTPServer(mcpServer)
462-
463-
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
464-
defer cancel()
465-
req, err := http.NewRequestWithContext(ctx, "GET", server.URL, nil)
466-
if err != nil {
467-
t.Fatalf("Failed to create request: %v", err)
468-
}
469-
req.Header.Set("Content-Type", "text/event-stream")
470-
471-
go func() {
472-
time.Sleep(10 * time.Millisecond)
473-
mcpServer.SendNotificationToAllClients("test/notification", map[string]any{
474-
"value": "all clients",
475-
})
476-
time.Sleep(10 * time.Millisecond)
477-
}()
478-
479-
resp, err := server.Client().Do(req)
480-
if err != nil {
481-
t.Fatalf("Failed to send message: %v", err)
482-
}
483-
defer resp.Body.Close()
484-
485-
if resp.StatusCode != http.StatusAccepted {
486-
t.Errorf("Expected status 202, got %d", resp.StatusCode)
487-
}
488-
489-
if resp.Header.Get("content-type") != "text/event-stream" {
490-
t.Errorf("Expected content-type text/event-stream, got %s", resp.Header.Get("content-type"))
491-
}
492-
493-
reader := bufio.NewReader(resp.Body)
494-
_, _ = reader.ReadBytes('\n') // skip first line for event type
495-
bodyBytes, err := reader.ReadBytes('\n')
496-
if err != nil {
497-
t.Fatalf("Failed to read response: %v, bytes: %s", err, string(bodyBytes))
498-
}
499-
if !strings.Contains(string(bodyBytes), "all clients") {
500-
t.Errorf("Expected all clients, got %s", string(bodyBytes))
501-
}
502-
}
503-
504457
func TestStreamableHTTP_HttpHandler(t *testing.T) {
505458
t.Run("Works with custom mux", func(t *testing.T) {
506459
mcpServer := NewMCPServer("test", "1.0.0")

0 commit comments

Comments
 (0)