waitConnected polls the hub until the agent is registered or timeout.
(t *testing.T, hub *Hub, agentID string)
| 98 | |
| 99 | // waitConnected polls the hub until the agent is registered or timeout. |
| 100 | func waitConnected(t *testing.T, hub *Hub, agentID string) { |
| 101 | t.Helper() |
| 102 | deadline := time.After(2 * time.Second) |
| 103 | for !hub.IsConnected(agentID) { |
| 104 | select { |
| 105 | case <-deadline: |
| 106 | t.Fatalf("timed out waiting for %s to register in hub", agentID) |
| 107 | default: |
| 108 | time.Sleep(10 * time.Millisecond) |
| 109 | } |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | // doHTTP does a plain HTTP GET (no upgrade) to the WS endpoint, sending the |
| 114 | // credential (when non-empty) as an Authorization: Bearer header. |
no test coverage detected