Skip to content

Commit 03cb5bf

Browse files
committed
chore: test order
1 parent 83de439 commit 03cb5bf

File tree

1 file changed

+45
-44
lines changed

1 file changed

+45
-44
lines changed

server/session_test.go

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -996,50 +996,6 @@ func TestMCPServer_ToolNotificationsDisabled(t *testing.T) {
996996
assert.Len(t, session.GetSessionTools(), 0)
997997
}
998998

999-
func TestSessionWithClientInfo_Integration(t *testing.T) {
1000-
server := NewMCPServer("test-server", "1.0.0")
1001-
1002-
session := &sessionTestClientWithClientInfo{
1003-
sessionID: "session-1",
1004-
notificationChannel: make(chan mcp.JSONRPCNotification, 10),
1005-
initialized: false,
1006-
}
1007-
1008-
err := server.RegisterSession(context.Background(), session)
1009-
require.NoError(t, err)
1010-
1011-
clientInfo := mcp.Implementation{
1012-
Name: "test-client",
1013-
Version: "1.0.0",
1014-
}
1015-
1016-
initRequest := mcp.InitializeRequest{}
1017-
initRequest.Params.ClientInfo = clientInfo
1018-
initRequest.Params.ProtocolVersion = mcp.LATEST_PROTOCOL_VERSION
1019-
initRequest.Params.Capabilities = mcp.ClientCapabilities{}
1020-
1021-
sessionCtx := server.WithContext(context.Background(), session)
1022-
1023-
// Retrieve the session from context
1024-
retrievedSession := ClientSessionFromContext(sessionCtx)
1025-
require.NotNil(t, retrievedSession, "Session should be available from context")
1026-
assert.Equal(t, session.SessionID(), retrievedSession.SessionID(), "Session ID should match")
1027-
1028-
// Check if the session can be cast to SessionWithClientInfo
1029-
sessionWithClientInfo, ok := retrievedSession.(SessionWithClientInfo)
1030-
require.True(t, ok, "Session should implement SessionWithClientInfo")
1031-
1032-
result, reqErr := server.handleInitialize(sessionCtx, 1, initRequest)
1033-
require.Nil(t, reqErr)
1034-
require.NotNil(t, result)
1035-
1036-
assert.True(t, sessionWithClientInfo.Initialized(), "Session should be initialized")
1037-
1038-
storedClientInfo := sessionWithClientInfo.GetClientInfo()
1039-
1040-
assert.Equal(t, clientInfo.Name, storedClientInfo.Name, "Client name should match")
1041-
assert.Equal(t, clientInfo.Version, storedClientInfo.Version, "Client version should match")
1042-
}
1043999
func TestMCPServer_SetLevelNotEnabled(t *testing.T) {
10441000
// Create server without logging capability
10451001
server := NewMCPServer("test-server", "1.0.0")
@@ -1125,3 +1081,48 @@ func TestMCPServer_SetLevel(t *testing.T) {
11251081
t.Errorf("Expected critical level, got %v", session.GetLogLevel())
11261082
}
11271083
}
1084+
1085+
func TestSessionWithClientInfo_Integration(t *testing.T) {
1086+
server := NewMCPServer("test-server", "1.0.0")
1087+
1088+
session := &sessionTestClientWithClientInfo{
1089+
sessionID: "session-1",
1090+
notificationChannel: make(chan mcp.JSONRPCNotification, 10),
1091+
initialized: false,
1092+
}
1093+
1094+
err := server.RegisterSession(context.Background(), session)
1095+
require.NoError(t, err)
1096+
1097+
clientInfo := mcp.Implementation{
1098+
Name: "test-client",
1099+
Version: "1.0.0",
1100+
}
1101+
1102+
initRequest := mcp.InitializeRequest{}
1103+
initRequest.Params.ClientInfo = clientInfo
1104+
initRequest.Params.ProtocolVersion = mcp.LATEST_PROTOCOL_VERSION
1105+
initRequest.Params.Capabilities = mcp.ClientCapabilities{}
1106+
1107+
sessionCtx := server.WithContext(context.Background(), session)
1108+
1109+
// Retrieve the session from context
1110+
retrievedSession := ClientSessionFromContext(sessionCtx)
1111+
require.NotNil(t, retrievedSession, "Session should be available from context")
1112+
assert.Equal(t, session.SessionID(), retrievedSession.SessionID(), "Session ID should match")
1113+
1114+
result, reqErr := server.handleInitialize(sessionCtx, 1, initRequest)
1115+
require.Nil(t, reqErr)
1116+
require.NotNil(t, result)
1117+
1118+
// Check if the session can be cast to SessionWithClientInfo
1119+
sessionWithClientInfo, ok := retrievedSession.(SessionWithClientInfo)
1120+
require.True(t, ok, "Session should implement SessionWithClientInfo")
1121+
1122+
assert.True(t, sessionWithClientInfo.Initialized(), "Session should be initialized")
1123+
1124+
storedClientInfo := sessionWithClientInfo.GetClientInfo()
1125+
1126+
assert.Equal(t, clientInfo.Name, storedClientInfo.Name, "Client name should match")
1127+
assert.Equal(t, clientInfo.Version, storedClientInfo.Version, "Client version should match")
1128+
}

0 commit comments

Comments
 (0)