MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / TestHandler_DisconnectUnregisters

Function TestHandler_DisconnectUnregisters

internal/ws/handler_test.go:373–403  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

371}
372
373func TestHandler_DisconnectUnregisters(t *testing.T) {
374 hub := NewHub()
375 defer hub.Close()
376 store := &mockStore{
377 user: newTestUser(),
378 agent: newTestAgent("user_1"),
379 }
380 handler := NewHandler(hub, store)
381 srv := startServer(t, handler)
382
383 conn, _ := dialWS(t, srv, "bot@agents.e2a.dev", "valid_key")
384 if conn == nil {
385 t.Fatal("expected successful WS connection")
386 }
387
388 waitConnected(t, hub, "agent_test")
389
390 // Close the connection
391 conn.Close(websocket.StatusNormalClosure, "bye")
392
393 // Wait for unregister to propagate
394 deadline := time.After(2 * time.Second)
395 for hub.IsConnected("agent_test") {
396 select {
397 case <-deadline:
398 t.Fatal("timed out waiting for unregister")
399 default:
400 time.Sleep(10 * time.Millisecond)
401 }
402 }
403}
404
405func TestHandler_SendAfterConnect(t *testing.T) {
406 hub := NewHub()

Callers

nothing calls this directly

Calls 9

CloseMethod · 0.95
IsConnectedMethod · 0.95
NewHubFunction · 0.85
newTestUserFunction · 0.85
newTestAgentFunction · 0.85
NewHandlerFunction · 0.85
startServerFunction · 0.85
dialWSFunction · 0.85
waitConnectedFunction · 0.85

Tested by

no test coverage detected