MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / TestCreateSessionPrunesUserSessionLimit

Function TestCreateSessionPrunesUserSessionLimit

server/mcp/handler_test.go:200–221  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

198}
199
200func TestCreateSessionPrunesUserSessionLimit(t *testing.T) {
201 srv := newTestServer(nil)
202 var firstSessionID string
203 for i := range maxUserSessions {
204 currentSession := srv.createSession(1)
205 if i == 0 {
206 firstSessionID = currentSession.id
207 }
208 }
209 srv.createSession(2)
210 srv.createSession(1)
211
212 if _, ok := srv.sessions[firstSessionID]; ok {
213 t.Fatal("expected oldest user session to be pruned")
214 }
215 if got := countSessionsForUser(srv, 1); got != maxUserSessions {
216 t.Fatalf("unexpected user session count: got %d want %d", got, maxUserSessions)
217 }
218 if got := len(srv.sessions); got != maxUserSessions+1 {
219 t.Fatalf("unexpected total session count: got %d want %d", got, maxUserSessions+1)
220 }
221}
222
223func TestCreateSessionPrunesGlobalSessionLimit(t *testing.T) {
224 srv := newTestServer(nil)

Callers

nothing calls this directly

Calls 3

newTestServerFunction · 0.85
countSessionsForUserFunction · 0.85
createSessionMethod · 0.45

Tested by

no test coverage detected