(t *testing.T)
| 371 | } |
| 372 | |
| 373 | func 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 | |
| 405 | func TestHandler_SendAfterConnect(t *testing.T) { |
| 406 | hub := NewHub() |
nothing calls this directly
no test coverage detected